Class VMap |
Instantiate class VMap in order to create a map. This is the central class in the API. Everything else is auxiliary. |
Constructor |
Constructor |
Description |
VMap(container, opts?) |
Creates a new map inside of the given HTML container, which is typically a DIV element. If no size is given in the optional argument opts.size , then the size of the container is used. If opts.size is given, then the container element of the map is resized accordingly. See class VMapOptions.
|
|
Methods |
Configuration |
Methods |
Return Value |
Description |
enableDragging() |
None |
Enables the dragging of the map (enabled by default). |
disableDragging() |
None |
Disables the dragging of the map. |
draggingEnabled() |
Boolean |
Returns true if the dragging of the map is enabled. |
enableInfoWindow() |
None |
Enables info window operations on the map (enabled by default). |
disableInfoWindow() |
None |
Closes the info window, if it is open, and disables the opening of a new info window. |
infoWindowEnabled() |
Boolean |
Returns true if the info window is enabled. |
enableDoubleClickPanCenter() |
None |
Enables double click to pan map to center (enabled by default). |
disableDoubleClickPanCenter() |
None |
Disables double click to pan map to center. |
doubleClickPanCenterEnabled() |
Boolean |
Returns true if double click to pan center is enabled. |
enableContinuousZoom() |
None |
Enables continuous smooth zooming (enabled by default). |
disableContinuousZoom() |
None |
Disables continuous smooth zooming. |
continuousZoomEnabled() |
Boolean |
Returns true if continuous smooth zooming is enabled. |
enableScrollWheelZoom() |
None |
Enables zooming using a mouse's scroll wheel (enabled by default). |
disableScrollWheelZoom() |
None |
Disables zooming using a mouse's scroll wheel. |
scrollWheelZoomEnabled() |
Boolean |
Returns true if scroll wheel zooming is enabled. |
|
Controls |
Methods |
Return Value |
Description |
addControl(control, position?) |
None |
Adds the control to the map. The position on the map is determined by the optional position argument. If this argument is absent, the default position of the control is used, as determined by the VControl.getDefaultPosition() method. A control instance must not be added more than once to the map. |
removeControl(control) |
None |
Removes the control from the map. It does nothing if the control was never added to the map. |
getContainer() |
Node |
Returns the DOM object that contains the map. Used by VControl.initialize(). |
|
Map State |
Methods |
Return Value |
Description |
isLoaded() |
Boolean |
Returns true if the map was initialized by setCenter() since it was created. |
getCenter() |
VLatLng |
Returns the geographical coordinates of the center point of the map view. |
getBounds() |
VLatLngBounds |
Returns the the visible rectangular region of the map view in geographical coordinates. |
getSize() |
VSize |
Returns the size of the map view in pixels. |
getLevel() |
Number |
Returns the current zoom level. |
|
Modify the Map State |
Methods |
Return Value |
Description |
setCenter(center, level?) |
None |
Sets the map view to the given center. This method must be called first after construction to set the initial state of the map. It is an error to call other operations on the map after construction. |
panTo(center) |
None |
Changes the center point of the map to the given point. If the point is already visible in the current map view, change the center in a smooth animation. |
panBy(distance) |
None |
Starts a pan animation by the given distance in pixels. |
panDirection(dx, dy) |
None |
Starts a pan animation by half the width of the map in the indicated directions. +1 is right and down, -1 is left and up, respectively. |
zoomToLevel(level) |
None |
Sets the zoom level to the given new value. |
zoomIn() |
None |
Increments zoom level by one. |
zoomOut() |
None |
Decrements zoom level by one. |
saveCurrentPosition() |
None |
Stores the current map position and zoom level for later recall by goToSavedPosition() . |
goToSavedPosition() |
None |
Restores the map view that was saved by saveCurrentPosition() . |
checkResize() |
None |
Call this method after the size of the container DOM object has changed, so that the map can adjust itself to fit the new size. |
fitOverlays() |
None |
Fit map that can see all overlays. |
|
Overlays |
Methods |
Return Value |
Description |
addOverlay(overlay) |
None |
Adds an overlay to the map and fires the addoverlay event. |
removeOverlay(overlay) |
None |
Removes the overlay from the map. If the overlay was on the map, it fires the removeoverlay event. |
clearOverlays() |
None |
Removes all overlay from the map, and fires the clearoverlays event. |
getOverlayContainer() |
None |
Returns a DIV that holds the overlay. |
|
Info Window |
Methods |
Return Value |
Description |
openInfoWindow(point, html, opts?) |
None |
Opens a simple info window at the given point. Pans the map such that the opened info window is fully visible. The content of the info window is given as HTML text. |
openInfoWindowTabs(point, tabs, opts?) |
None |
Opens a tabbed info window at the given point. Pans the map such that the opened info window is fully visible. The content of the info window is given as HTML text. |
showMapBlowup(point, opts?) |
None |
Opens an info window at the given point that contains a closeup view on the map around this point. |
updateInfoWindow(tabs, onupdate?) |
None |
Updates the content of the currently open VInfoWindow object, without repositioning. The info window is resized to fit the new content. The optional onupdate callback function is called after the info window content is actually changed. |
closeInfoWindow() |
None |
Closes the currently open info window. |
getInfoWindow() |
VInfoWindow |
Returns the info window object of this map. |
|
Coordinate Transformations |
Methods |
Return Value |
Description |
fromLatLngToDivPixel(latlng) |
VPoint |
Computes the pixel coordinates of the given geographical point in the DOM element that holds the draggable map. You need this method to position a custom overlay when you implement the VOverlay.redraw() method for a custom overlay. |
fromDivPixelToLatLng(pixel) |
VLatLng |
Computes the geographical coordinates from pixel coordinates in the div that holds the draggable map. You need this when you implement interaction with custom overlays. |
fromContainerPixelToLatLng (pixel) |
VLatLng |
Computes the geographical coordinates of the point at the given pixel coordinates in the DOM element that contains the map on the page. You need this when you implement interaction of custom controls with the map. |
|
Events |
Events |
Arguments |
Description |
click |
overlay, point |
This event is fired when the map is clicked with the mouse. If the click was on a marker, then the marker is passed to the event handler in the overlay argument, and a click event is also fired on the marker. Otherwise, the geographical coordinates of the point that was clicked are passed in the point argument. |
dblclick |
overlay, point |
This event is fired when the map is double clicked with the mouse. If the click was on a marker, then the marker is passed to the event handler in the overlay argument, and a dblclick event is also fired on the marker. Otherwise, the geographical coordinates of the point that was clicked are passed in the point argument. |
singlerightclick |
overlay, point |
This event is fired when the DOM contextmenu event is fired on the map container. |
movestart |
None |
This event is fired when the map view starts changing. This can be caused by dragging, in which case a dragstart event is also fired, or by invocation of a method that changes the map view. |
moving |
None |
This event is fired, possibly repeatedly, while the map view is changing. |
moveend |
None |
This event is fired when the change of the map view ends. |
zoomend |
oldLevel, newLevel |
This event is fired when the map reaches a new zoom level. The event handler receives the previous and the new zoom level as arguments. |
infowindowopen |
None |
This event is fired when the info window opens. |
infowindowbeforeclose |
None |
This event is fired before the info window closes. |
infowindowclose |
None |
This event is fired when the info window closes. |
addoverlay |
overlay |
This event is fired when a single overlay is added to the map by the method addOverlay() . The new overlay is passed as an argument overlay to the event handler. |
removeoverlay |
overlay |
This event is fired when a single overlay is removed by the method removeOverlay() . The overlay that was removed is passed as an argument overlay to the event handler. |
clearoverlays |
None |
This event is fired when all overlays are removed at once by the method clearOverlays() . |
mouseover |
latlng |
This event is fired when the user moves the mouse over the map from outside the map. |
mouseout |
latlng |
This event is fired when the user moves the mouse off the map. |
mousemove |
latlng |
This event is fired when the user moves the mouse inside the map. |
dragstart |
None |
This event is fired when the user starts dragging the map. |
dragging |
None |
This event is repeatedly fired while the user drags the map. |
dragend |
None |
This event is fired when the user stops dragging the map. |
loaded |
None |
This event is fired when the map setup is complete, and isLoaded would return true . This means position, zoom, and map type are all initialized, but tile images may still be loading. |
|
Class VMarker |
A VMarker marks a position on the map. It implements the VOverlay interface and thus is added to the map using the VMap.addOverlay() method.
A marker object has a point, which is the geographical position where the marker is anchored on the map, and an icon. If the icon is not set in the constructor, the default icon V_DEFAULT_ICON is used.
After it is added to a map, the info window of that map can be opened through the marker. The marker object will fire mouse events and infowindow events. |
Constructor |
Constructor |
Description |
VMarker(point, icon?, inert?) |
Creates a marker at the passed point with icon or the V_DEFAULT_ICON . If the inert flag is true , then the marker is not clickable and will not fire any events. |
VMarker(latlng, opts?) |
Creates a marker at the latlng with options specified in VMarkerOptions . By default markers are clickable & have the default icon V_DEFAULT_ICON . |
|
Methods |
Before these methods can be invoked, the marker must be added to a map.
|
Methods |
Return Value |
Description |
openInfoWindow(content, opts?) |
None |
Opens the map info window over the icon of the marker. The content of the info window is given as a string that contains HTML text. |
bindInfoWindow(content, opts?) |
None |
Binds the given VInfoWindowTabs (provided as strings of HTML) to this marker. The HTML content within these tabs will be automatically displayed in the info window when the marker is clicked. Pass tabs as null to unbind. |
closeInfoWindow() |
None |
Closes the info window only if it belongs to this marker. |
showMapBlowup(opts?) |
None |
Opens the map info window over the icon of the marker. The content of the info window is a closeup map around the marker position. |
getIcon() |
VIcon |
Returns the icon of this marker, as set by the constructor. |
getTitle() |
String |
Returns the title of this marker, as set by the constructor via the VMarkerOptions . |
getPoint() |
VLatLng |
Returns the geographical coordinates at which this marker is anchored. |
setPoint(point) |
None |
Sets the geographical coordinates of the point at which this marker is anchored. |
enableDragging() |
None |
Enables the marker to be dragged and dropped around the map. |
disableDragging() |
None |
Disables the marker from being dragged and dropped around the map. |
draggable() |
Boolean |
Returns true if the marker has been initialized via the constructor using VMarkerOptions.draggable = true . |
hide() |
None |
Hides the marker if it is currently visible. Note that this function triggers the event VMarker.visibilitychanged in case the marker is currently visible. |
show() |
None |
Shows the marker if it is currently hidden. Note that this function triggers the event VMarker.visibilitychanged in case the marker is currently hidden. |
isHidden() |
Boolean |
Returns true if the marker is currently hidden. Otherwise returns false . |
|
Events |
Events |
Arguments |
Description |
click |
None |
This event is fired when the marker icon was clicked. Notice that this event will also fire for the map, with the marker passed as the first argument to the event handler there. |
dblclick |
None |
This event is fired when the marker icon was double-clicked. |
mousedown |
None |
This event is fired when the DOM mousedown event is fired on the marker icon. Notice that the marker will stop the mousedown DOM event, so that it doesn't cause the map to start dragging. |
mouseup |
None |
This event is fired for the DOM mouseup on the marker. Notice that the marker will not stop the mousedown DOM event, because it will not confuse the drag handler of the map. |
mouseover |
None |
This event is fired when the mouse enters the area of the marker icon. |
mouseout |
None |
This event is fired when the mouse enters the area of the marker icon. |
infowindowopen |
None |
This event is fired when the info window of the map was opened through this marker. |
infowindowbeforeclose |
None |
This event is fired before the info window of the map that was opened through this marker is closed. |
infowindowclose |
None |
This event is fired when the info window of the map that was opened through this marker is closed. This happens when either the info window was closed, or when it was opened on another marker, or on the map. The event infowindowbeforeclose is fired before this event. |
remove |
None |
This event is fired when the marker is removed from the map, using VMap.removeOverlay() or VMap.clearOverlays() . |
dragstart |
None |
If the marker is enabled for dragging, this event is fired when the marker dragging begins. |
dragging |
None |
If the marker is enabled for dragging, this event is fired when the marker is being dragged. |
dragend |
None |
If the marker is enabled for dragging, this event is fired when the marker ceases to be dragged. |
visibilitychanged |
isVisible |
This event is fired when the visibility of the marker is changed (i.e. the visibility is flipped from visible to hidden or vice-versa). isVisible refers to the state of the marker after the visibility change has happened. |
|
Class VPolyline |
This is a map overlay that draws a polyline on the map, using the vector drawing facilities of the browser if they are available. |
Constructor |
Constructor |
Description |
VPolyline(latlngs, lineColor?, lineWidth?, fillColor? opacity?, opts?) |
Creates a polyline from an array of vertices. linecolor, fillcolor is given as a string that contains the color in hexadecimal numeric HTML style (#RRGGBB). lineWidth the width of the line in pixels. opacity is given as a number between 0 and 1. |
|
Methods |
Methods |
Return Value |
Description |
getVertexCount() |
Number |
Returns the number of vertices in the polyline. |
getVertex(index) |
VLatLng |
Returns the vertex with the given index in the polyline. |
hide() |
None |
Hides the polyline if it is both currently visible. |
isHidden() |
Boolean |
Returns true if the polyline is currently hidden. Otherwise returns false . |
show() |
None |
Shows the polyline if it is currently hidden. |
|
Events |
Events |
Arguments |
Description |
remove |
None |
This event is fired when the polyline is removed from the map, using VMap.removeOverlay() or VMap.clearOverlays() . |
visibilitychanged |
isVisible |
This event is fired when the visibility state of the polyline toggles from visible to hidden or vice versa. The isVisible argument reflects the state of the polyline after completion of this visibility state. |
click |
latlng |
This event is fired when the polyline is clicked. |
|
Class VPolygon |
This is very similar to a VPolyline . |
Constructor |
Constructor |
Description |
VPolygon(latlngs, lineColor?, lineWidth?, fillColor? opacity?, opts?) |
Creates a polygon from an array of vertices. linecolor, fillcolor is given as a string that contains the color in hexadecimal numeric HTML style (#RRGGBB). lineWidth the width of the line in pixels. opacity is given as a number between 0 and 1. |
|
Methods |
Methods |
Return Value |
Description |
getVertexCount() |
Number |
Returns the number of vertices in the polygon. |
getVertex(index) |
VLatLng |
Returns the vertex with the given index in the polygon. |
hide() |
None |
Hides the polygon if it is both currently visible. |
isHidden() |
Boolean |
Returns true if the polygon is currently hidden. Otherwise returns false . |
show() |
None |
Shows the polygon if it is currently hidden. |
|
Events |
Events |
Arguments |
Description |
remove |
None |
This event is fired when the polygon is removed from the map, using VMap.removeOverlay() or VMap.clearOverlays() . |
visibilitychanged |
isVisible |
This event is fired when the visibility state of the polygon toggles from visible to hidden or vice versa. The isVisible argument reflects the state of the polygon after completion of this visibility state. |
click |
latlng |
This event is fired when the polygon is clicked. |
|
Class VDirections |
This class is used to obtain driving directions results and display them on a map and/or a text panel. |
Constructor |
Constructor |
Description |
VDirections(map?, panel?) |
Creates a new instance of a directions object to request and store direction results. This directions object can then create directions given a query using the VDirections.load() method. The constructor takes an optional map object (to display a polyline of the computed directions) and/or a panel DIV element (to display textual direction results. If passed a map argument, whenever a new directions result is computed, the polyline and markers associated with the result are automatically added as overlays on the map. Similarly, when passed a panel argument, the textual directions associated with the result are added to the indicated DIV, replacing any existing content in the DIV. Additionally, the object contains three event listeners which you can intercept: "load": This event is triggered when the results of a directions query issued via VDirections .load() are available. Note that the load() method initiates a new query, which in turn triggers a "load" event once the query has finished loading. |
|
Methods |
Methods |
Return Value |
Description |
load(query, queryOpts) |
None |
This method issues a new directions query. The query parameter is a string containing any valid directions query, e.g "from: Tp Hồ Chí Minh to: Hà Nội" or "From: 21 Nguyễn Văn Trỗi, Phú Nhuận To: Vũng Tàu". When directions results are received, this object clears old results, replacing them with new ones and updating the map and/or panel with new results. |
loadFromWayPoints(waypoints, queryOpts) |
None |
Issues a new directions query using an array of waypoints as input instead of a single query string. Each entry in the array is a string representing an input address or a lat,lng point. |
clear() |
None |
Clears any existing directions results, removes overlays from the map and panel, and cancels any pending load() requests. |
getStatus() |
Boolean |
Returns the status of the directions request. |
getBounds() |
VLatLngBounds |
This method is used to get the bounding box for the result of this directions query. Returns a VLatLngBounds object or null if no successful result is available. |
getNumRoutes() |
Number |
Returns the number of routes available in the result. |
getRoute(i) |
VRoute |
Return the VRoute object for the ith route in the response. |
getSummaryHTML() |
String |
Returns an HTML snippet containing a summary of the distance. |
getDistance() |
String |
Returns an object literal representing the total distance of the directions request. |
getMarker(i) |
VMarker |
Return the ith marker. |
|
Events |
Events |
Arguments |
Description |
loaded |
None |
Fire when find path complete. |
|