Instantiates a map object given a div element id and optionally an object literal with map options described below.
Attribution control.
Box (shift-drag with mouse) zoom handler.
Double click zoom handler.
Map dragging handler (by both mouse and touch).
Keyboard navigation handler.
Map state options
Scroll wheel zoom handler.
Mobile touch hacks (quick tap and touch hold) handler.
Touch zoom handler.
Zoom control.
Sets a map view that contains the given geographical bounds with the maximum zoom level possible.
Sets a map view that mostly contains the whole world with the maximum zoom level possible.
Returns the LatLngBounds of the current map view.
Returns the maximum zoom level on which the given bounds fit to the map view in its entirety. If inside (optional) is set to true, the method instead returns the minimum zoom level on which the map view fits into the given bounds in its entirety.
Returns the geographical center of the map view.
Returns the container element of the map.
Returns the maximum zoom level of the map.
Returns the minimum zoom level of the map.
Returns an object with different map panes (to render overlays in).
Returns the bounds of the current map view in projected pixel coordinates (sometimes useful in layer and overlay implementations).
Returns the projected pixel coordinates of the top left point of the map layer (useful in custom layer and overlay implementations).
Returns the current size of the map container.
Returns the current zoom of the map view.
Returns true if the given layer is currently added to the map.
Checks if the map container size changed and updates the map if so — call it after you've changed the map size dynamically, also animating pan by default. If options.pan is false, panning will not occur.
Checks if the map container size changed and updates the map if so — call it after you've changed the map size dynamically, also animating pan by default.
Tries to locate the user using Geolocation API, firing locationfound event with location data on success or locationerror event on failure, and optionally sets the map view to the user location with respect to detection accuracy (or to the world view if geolocation failed). See Locate options for more details.
Returns the pixel coordinates of a mouse click (relative to the top left corner of the map) given its event object.
Returns the geographical coordinates of the point the mouse clicked on given the click's event object.
Returns the pixel coordinates of a mouse click relative to the map layer given its event object.
Opens the specified popup while closing the previously opened (to make sure only one is opened at one time for usability).
Creates a popup with the specified options and opens it in the given point on a map.
Creates a popup with the specified options and opens it in the given point on a map.
Pans the map by a given number of pixels (animated).
Pans the map to the closest view that would lie inside the given bounds (if it's not already).
Pans the map to a given center. Makes an animated pan if new center is not more than one screen away from the current one.
Destroys the map and clears all related event listeners.
Restricts the map view to the given bounds (see map maxBounds option),
passing the given animation options through to setView
, if required.
Sets the view of the map (geographical center and zoom) with the given animation options.
Sets the zoom of the map.
Zooms the map while keeping a specified point on the map stationary (e.g. used internally for scroll zoom and double-click zoom).
Stops watching location previously initiated by map.locate({watch: true}) and aborts resetting the map view if map.locate was called with {setView: true}.
Increases the zoom of the map by delta (1 by default).
Decreases the zoom of the map by delta (1 by default).
You can also use the following shortcut when you just need to make one additional method call.
You use L.Class.extend to define new classes, but you can use the same method on any class to inherit from it.
Instantiates a map object given a div element and optionally an object literal with map options described below.