Methods (Map)
Methods for changing the map status from v3
Name | Return | Description |
---|---|---|
setView(LatLng center, int zoom?, zoom/pan options options?) |
this |
Defines the view of the map (geographical center and zoom) with the given animation options. |
setZoom(int zoom, zoom options options?) |
this |
Sets the zoom of the map. |
zoomIn(int delta?, zoom options options?) |
this |
Increases the zoom of the map by delta (default 1). |
zoomOut(int delta?, zoom options options?) |
this |
Decreases the zoom of the map by delta (default 1). |
setZoomAround(LatLng latlng, int zoom, zoom options options?) |
this |
Shrinks the map while a specific point on the map remains stationary (for example, used internally for scroll zoom and double-click zoom) |
fitBounds(LatLngBounds bounds, fitBounds options options?) |
this |
Defines a map view that contains the specified geographical boundaries with the maximum possible zoom level. |
fitWorld(fitBounds options options?) |
this |
Defines a map view that usually contains the whole world with the maximum possible zoom level. |
panTo(LatLng latlng, pan options options?) |
this |
Moves the map to a specific center. Animates the move action when the new center is no more than one screen away from the current center. |
panInsideBounds(LatLngBounds bounds, pan options options?) |
this |
Moves the map to the closest view that would be within the specified limits (if not already there), and controls the animation with the specific options, if available. |
panBy(Point point, pan options options?) |
this |
Moves the map by a certain number of pixels (animated) |
invalidateSize(bool animate) |
this |
Checks if the size of the map container has changed and updates the map; if so, call it after dynamically changing the map size, and by default, animate the move action as well. |
invalidateSize(zoom/pan options options) |
this |
Checks if the size of the map container has changed and updates the map; if so, call it after dynamically changing the map size, and by default, animate the move action as well. |
setMaxBounds(LatLngBounds bounds |
this |
Restricts the map view to the specified limits. |
locate(Locate options options?) |
this |
Attempts to determine the user's location using the Geolocation API and then triggers a locationfound -event. If successful, it returns the location data, otherwise locationerror . Optionally sets the map view to the user's location in terms of recognition accuracy (or to the world view if geolocation has failed) See the Search Options for more information. |
stopLocate() |
this |
Terminates the location determination by map.locate({watch: true}) and cancels the map resetting if map.locate was called in the following way: {setView: true} . |
remove() |
this |
Destroys the card and deletes all event receivers connected to it. |
Methods that read the card status from v3
Name | Return | Description |
---|---|---|
getCenter() |
LatLng |
Returns the geographic center of the map view. |
getZoom() |
int |
Returns the current zoom of the map view. |
getMinZoom() |
int |
Returns the minimum zoom level of the map. |
getMaxZoom() |
int |
Returns the maximum zoom level of the map. |
getBounds() |
LatLngBounds |
Returns LatLngBounds of the current map view. |
getBoundsZoom(LatLngBounds bounds, bool inside?) |
int |
Returns the maximum zoom level at which the specified limits fit the map view in its entirety. If inside (optional) is set to true, the method instead returns the minimum zoom level at which the map view completely fits within the specified boundaries. |
getSize() |
Point |
Returns the current size of the map container. |
getPixelBounds() |
Bounds |
Returns the borders of the current map view in projected pixel coordinates (sometimes useful in layer and overlay implementations) |
getPixelOrigin() |
Point |
Returns the projected pixel coordinates of the upper left point of the map layer (useful for custom layer and overlay implementations). |
Methods for layers and control elements from v3
Name | Return | Description |
---|---|---|
addLayer(ILayer layer) |
this |
Adds the specified layer to the map. |
removeLayer(ILayer layer) |
this |
Removes the specified layer from the map. |
hasLayer(ILayer layer) |
bool |
Returns true if the specified layer is currently added to the map. |
eachLayer(Function fn, Object context?) |
this |
Iterates over the layers of the map and optionally gives the context of the iterator function. map.eachLayer( function (layer) { layer.bindPopup("Hello"); }); |
openPopup(Popup popup) |
this |
Opens the specified popup while closing the previously opened one (to ensure that only one popup is open at a time). This ensures a special user-friendliness. |
openPopup(String html | HTMLElement el, LatLng latlng, Popup options options?) |
this |
Creates a popup with the specified options and opens it at the specified point on a map. |
closePopup(Popup popup?) |
this |
Closes the popup previously opened with openPopup (or the specified one). |
addControl(IControl control) |
this |
Adds the given control to the map. |
removeControl(IControl control) |
this |
Removes the specified control from the map. |
Conversion methods from v3
Name | Return | Description |
---|---|---|
latLngToLayerPoint(LatLng latlng) |
Point |
Returns the point of the map layer corresponding to the given geographic coordinates (useful for placing overlays on the map). |
layerPointToLatLng(Point point) |
LatLng |
Returns the geographic coordinates of a given map layer point. |
containerPointToLayerPoint(Point point) |
Point |
Converts the point relative to the map container into a point relative to the map layer. |
layerPointToContainerPoint(Point point) |
Point |
Converts the point relative to the map layer into a point relative to the map container. |
latLngToContainerPoint(LatLng latlng) |
Point |
Returns the map container point corresponding to the given geographic coordinates. |
containerPointToLatLng(Point point) |
LatLng |
Returns the geographic coordinates of a given map container point. |
project(LatLng latlng, Number zoom?) |
Point |
Projects the specified geographic coordinates to absolute pixel coordinates for the specified zoom level (the current zoom level by default). |
unproject(Point point, Number zoom?) |
LatLng |
Projects the specified absolute pixel coordinates to geographic coordinates for the specified zoom level (the current zoom level by default). |
mouseEventToContainerPoint(MouseEvent event) |
Point |
Returns the pixel coordinates of a mouse click (relative to the upper left corner of the map) in relation to the event object. |
mouseEventToLayerPoint(MouseEvent event) |
Point |
Returns the pixel coordinates of a mouse click relative to the map layer assigned to the event object |
mouseEventToLatLng(MouseEvent event) |
LatLng |
Returns the geographic coordinates of the point on which the mouse clicked, if the click event object is specified. |
Further methods from v3
Name | Return | Description |
---|---|---|
getContainer() |
HTMLElement |
Returns the container element of the map. |
getPanes() |
MapPanes |
Returns an object with different map sections (for rendering overlays) |
whenReady(Function fn, Object context?) |
this |
Executes the specified callback at the moment the map is initialized with a location and zoom, or it executes it immediately if the initialization was already completed. Optionally, a function context can be passed. |