L.Class powers the OOP facilities of Leaflet and is used to create
almost all of the Leaflet classes documented.
Methods
public addControl( control: IControl ) : Map
Defined in leaflet/leaflet.d.ts:2149
Adds the given control to the map.
Parameters
Returns
Map
public addEventListener( type: string , fn: (e: L.LeafletEvent) => void , context?: any ) : Map
Defined in leaflet/leaflet.d.ts:2291
Parameters
type: string
fn: (e: L.LeafletEvent) => void
context?: any optional
Returns
Map
public addEventListener( eventMap: any , context?: any ) : Map
Defined in leaflet/leaflet.d.ts:2299
Parameters
eventMap: any
context?: any optional
Returns
Map
public addLayer( layer: ILayer , insertAtTheBottom?: boolean ) : Map
Defined in leaflet/leaflet.d.ts:2111
Adds the given layer to the map. If optional insertAtTheBottom is set to true,
the layer is inserted under all others (useful when switching base tile layers).
Parameters
insertAtTheBottom?: boolean optional
Returns
Map
public addOneTimeEventListener( type: string , fn: (e: L.LeafletEvent) => void , context?: any ) : Map
Defined in leaflet/leaflet.d.ts:2292
Parameters
type: string
fn: (e: L.LeafletEvent) => void
context?: any optional
Returns
Map
public clearAllEventListeners( ) : Map
Defined in leaflet/leaflet.d.ts:2301
Returns
Map
public closePopup( ) : Map
Defined in leaflet/leaflet.d.ts:2144
Closes the popup previously opened with openPopup (or the given one).
Returns
Map
public containerPointToLatLng( point: Point ) : LatLng
Defined in leaflet/leaflet.d.ts:2190
Returns the geographical coordinates of a given map container point.
Parameters
Returns
LatLng
public containerPointToLayerPoint( point: Point ) : Point
Defined in leaflet/leaflet.d.ts:2173
Converts the point relative to the map container to a point relative to the
map layer.
Parameters
Returns
Point
public fire( type: string , data?: any ) : Map
Defined in leaflet/leaflet.d.ts:2299
Parameters
type: string
data?: any optional
Returns
Map
public fireEvent( type: string , data?: any ) : Map
Defined in leaflet/leaflet.d.ts:2295
Parameters
type: string
data?: any optional
Returns
Map
Defined in leaflet/leaflet.d.ts:1989
Sets a map view that contains the given geographical bounds with the maximum
zoom level possible.
Parameters
Returns
Map
Defined in leaflet/leaflet.d.ts:1995
Sets a map view that mostly contains the whole world with the maximum zoom
level possible.
Parameters
Returns
Map
Defined in leaflet/leaflet.d.ts:2078
Returns the LatLngBounds of the current map view.
Returns
LatLngBounds
public getBoundsZoom( bounds: LatLngBounds , inside?: boolean ) : number
Defined in leaflet/leaflet.d.ts:2086
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.
Parameters
inside?: boolean optional
Returns
number
public getCenter( ) : LatLng
Defined in leaflet/leaflet.d.ts:2058
Returns the geographical center of the map view.
Returns
LatLng
public getContainer( ) : HTMLElement
Defined in leaflet/leaflet.d.ts:2227
Returns the container element of the map.
Returns
HTMLElement
public getMaxZoom( ) : number
Defined in leaflet/leaflet.d.ts:2073
Returns the maximum zoom level of the map.
Returns
number
public getMinZoom( ) : number
Defined in leaflet/leaflet.d.ts:2068
Returns the minimum zoom level of the map.
Returns
number
public getPanes( ) : MapPanes
Defined in leaflet/leaflet.d.ts:2232
Returns an object with different map panes (to render overlays in).
Returns
MapPanes
public getPixelBounds( ) : Bounds
Defined in leaflet/leaflet.d.ts:2097
Returns the bounds of the current map view in projected pixel coordinates
(sometimes useful in layer and overlay implementations).
Returns
Bounds
public getPixelOrigin( ) : Point
Defined in leaflet/leaflet.d.ts:2103
Returns the projected pixel coordinates of the top left point of the map layer
(useful in custom layer and overlay implementations).
Returns
Point
public getSize( ) : Point
Defined in leaflet/leaflet.d.ts:2091
Returns the current size of the map container.
Returns
Point
public getZoom( ) : number
Defined in leaflet/leaflet.d.ts:2063
Returns the current zoom of the map view.
Returns
number
public hasEventListeners( type: string ) : boolean
Defined in leaflet/leaflet.d.ts:2294
Parameters
Returns
boolean
public hasLayer( layer: ILayer ) : boolean
Defined in leaflet/leaflet.d.ts:2121
Returns true if the given layer is currently added to the map.
Parameters
Returns
boolean
Defined in leaflet/leaflet.d.ts:2019
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.
Parameters
Returns
Map
public invalidateSize( animate: boolean ) : Map
Defined in leaflet/leaflet.d.ts:2025
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.
Parameters
Returns
Map
public latLngToContainerPoint( latlng: LatLng ) : Point
Defined in leaflet/leaflet.d.ts:2185
Returns the map container point that corresponds to the given geographical
coordinates.
Parameters
Returns
Point
public latLngToLayerPoint( latlng: LatLng ) : Point
Defined in leaflet/leaflet.d.ts:2162
Returns the map layer point that corresponds to the given geographical coordinates
(useful for placing overlays on the map).
Parameters
Returns
Point
public layerPointToContainerPoint( point: Point ) : Point
Defined in leaflet/leaflet.d.ts:2179
Converts the point relative to the map layer to a point relative to the map
container.
Parameters
Returns
Point
public layerPointToLatLng( point: Point ) : LatLng
Defined in leaflet/leaflet.d.ts:2167
Returns the geographical coordinates of a given map layer point.
Parameters
Returns
LatLng
Defined in leaflet/leaflet.d.ts:2040
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.
Parameters
Returns
Map
Defined in leaflet/leaflet.d.ts:2208
Returns the pixel coordinates of a mouse click (relative to the top left corner
of the map) given its event object.
Parameters
Returns
Point
Defined in leaflet/leaflet.d.ts:2220
Returns the geographical coordinates of the point the mouse clicked on given
the click's event object.
Parameters
Returns
LatLng
Defined in leaflet/leaflet.d.ts:2214
Returns the pixel coordinates of a mouse click relative to the map layer given
its event object.
Parameters
Returns
Point
public off( type: string , fn?: (e: L.LeafletEvent) => void , context?: any ) : Map
Defined in leaflet/leaflet.d.ts:2298
Parameters
type: string
fn?: (e: L.LeafletEvent) => void optional
context?: any optional
Returns
Map
public off( eventMap?: any , context?: any ) : Map
Defined in leaflet/leaflet.d.ts:2303
Parameters
eventMap?: any optional
context?: any optional
Returns
Map
public on( type: string , fn: (e: L.LeafletEvent) => void , context?: any ) : Map
Defined in leaflet/leaflet.d.ts:2296
Parameters
type: string
fn: (e: L.LeafletEvent) => void
context?: any optional
Returns
Map
public on( eventMap: any , context?: any ) : Map
Defined in leaflet/leaflet.d.ts:2302
Parameters
eventMap: any
context?: any optional
Returns
Map
public once( type: string , fn: (e: L.LeafletEvent) => void , context?: any ) : Map
Defined in leaflet/leaflet.d.ts:2297
Parameters
type: string
fn: (e: L.LeafletEvent) => void
context?: any optional
Returns
Map
public openPopup( popup: Popup ) : Map
Defined in leaflet/leaflet.d.ts:2127
Opens the specified popup while closing the previously opened (to make sure
only one is opened at one time for usability).
Parameters
Returns
Map
public openPopup( html: string , latlng: LatLng , options?: PopupOptions ) : Map
Defined in leaflet/leaflet.d.ts:2133
Creates a popup with the specified options and opens it in the given point
on a map.
Parameters
Returns
Map
public openPopup( el: HTMLElement , latlng: LatLng , options?: PopupOptions ) : Map
Defined in leaflet/leaflet.d.ts:2139
Creates a popup with the specified options and opens it in the given point
on a map.
Parameters
Returns
Map
Defined in leaflet/leaflet.d.ts:2012
Pans the map by a given number of pixels (animated).
Parameters
Returns
Map
public panInsideBounds( bounds: LatLngBounds ) : Map
Defined in leaflet/leaflet.d.ts:2007
Pans the map to the closest view that would lie inside the given bounds (if
it's not already).
Parameters
Returns
Map
Defined in leaflet/leaflet.d.ts:2001
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.
Parameters
Returns
Map
public project( latlng: LatLng , zoom?: number ) : Point
Defined in leaflet/leaflet.d.ts:2196
Projects the given geographical coordinates to absolute pixel coordinates
for the given zoom level (current zoom level by default).
Parameters
Returns
Point
public remove( ) : Map
Defined in leaflet/leaflet.d.ts:2051
Destroys the map and clears all related event listeners.
Returns
Map
public removeControl( control: IControl ) : Map
Defined in leaflet/leaflet.d.ts:2154
Removes the given control from the map.
Parameters
Returns
Map
public removeEventListener( type: string , fn?: (e: L.LeafletEvent) => void , context?: any ) : Map
Defined in leaflet/leaflet.d.ts:2293
Parameters
type: string
fn?: (e: L.LeafletEvent) => void optional
context?: any optional
Returns
Map
public removeEventListener( eventMap?: any , context?: any ) : Map
Defined in leaflet/leaflet.d.ts:2300
Parameters
eventMap?: any optional
context?: any optional
Returns
Map
public removeLayer( layer: ILayer ) : Map
Defined in leaflet/leaflet.d.ts:2116
Removes the given layer from the map.
Parameters
Returns
Map
Defined in leaflet/leaflet.d.ts:2031
Restricts the map view to the given bounds (see map maxBounds option),
passing the given animation options through to setView
, if required.
Parameters
Returns
Map
public setView( center: LatLng , zoom: number , options?: ZoomPanOptions ) : Map
Defined in leaflet/leaflet.d.ts:1962
Sets the view of the map (geographical center and zoom) with the given
animation options.
Parameters
Returns
Map
public setZoom( zoom: number , options?: ZoomOptions ) : Map
Defined in leaflet/leaflet.d.ts:1967
Sets the zoom of the map.
Parameters
Returns
Map
public setZoomAround( latlng: LatLng , zoom: number , options?: ZoomOptions ) : Map
Defined in leaflet/leaflet.d.ts:1983
Zooms the map while keeping a specified point on the map stationary
(e.g. used internally for scroll zoom and double-click zoom).
Parameters
Returns
Map
public stopLocate( ) : Map
Defined in leaflet/leaflet.d.ts:2046
Stops watching location previously initiated by map.locate({watch: true})
and aborts resetting the map view if map.locate was called with {setView: true}.
Returns
Map
public unproject( point: Point , zoom?: number ) : LatLng
Defined in leaflet/leaflet.d.ts:2202
Projects the given absolute pixel coordinates to geographical coordinates
for the given zoom level (current zoom level by default).
Parameters
Returns
LatLng
public whenReady( fn: (map: L.Map) => void , context?: any ) : Map
Defined in leaflet/leaflet.d.ts:2239
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.
Parameters
fn: (map: L.Map) => void
context?: any optional
Returns
Map
public zoomIn( delta?: number , options?: ZoomOptions ) : Map
Defined in leaflet/leaflet.d.ts:1972
Increases the zoom of the map by delta (1 by default).
Parameters
Returns
Map
public zoomOut( delta?: number , options?: ZoomOptions ) : Map
Defined in leaflet/leaflet.d.ts:1977
Decreases the zoom of the map by delta (1 by default).
Parameters
Returns
Map