L.Class powers the OOP facilities of Leaflet and is used to create almost all of the Leaflet classes documented.
Instantiates a map object given a div element and optionally an object literal with map options described below.
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.
Scroll wheel zoom handler.
Mobile touch hacks (quick tap and touch hold) handler.
Touch zoom handler.
Zoom control.
Adds the given control to the map.
any
Closes the popup previously opened with openPopup (or the given one).
Returns the geographical coordinates of a given map container point.
Converts the point relative to the map container to a point relative to the map layer.
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.
number
Returns the geographical center of the map view.
Returns the container element of the map.
HTMLElement
Returns the maximum zoom level of the map.
number
Returns the minimum zoom level of the map.
number
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.
any
Returns the current zoom of the map view.
number
boolean
Returns true if the given layer is currently added to the map.
boolean
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.
Returns the map container point that corresponds to the given geographical coordinates.
Returns the map layer point that corresponds to the given geographical coordinates (useful for placing overlays on the map).
Converts the point relative to the map layer to a point relative to the map container.
Returns the geographical coordinates of a given map layer point.
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.
Projects the given geographical coordinates to absolute pixel coordinates for the given zoom level (current zoom level by default).
Destroys the map and clears all related event listeners.
Removes the given control from the map.
Removes the given layer from the map.
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}.
Projects the given absolute pixel coordinates to geographical coordinates for the given zoom level (current zoom level by default).
Runs the given callback when the map gets initialized with a place and zoom, or immediately if it happened already, optionally passing a function context.
Increases the zoom of the map by delta (1 by default).
Decreases the zoom of the map by delta (1 by default).