Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Map

Hierarchy

Implements

Index

Constructors

constructor

  • Instantiates a map object given a div element and optionally an object literal with map options described below.

    constructor

    Parameters

    Returns Map

  • Instantiates a map object given a div element id and optionally an object literal with map options described below.

    constructor

    Parameters

    Returns Map

Properties

attributionControl

attributionControl: Attribution

Attribution control.

boxZoom

boxZoom: IHandler

Box (shift-drag with mouse) zoom handler.

doubleClickZoom

doubleClickZoom: IHandler

Double click zoom handler.

dragging

dragging: IHandler

Map dragging handler (by both mouse and touch).

keyboard

keyboard: IHandler

Keyboard navigation handler.

options

options: MapOptions

Map state options

scrollWheelZoom

scrollWheelZoom: IHandler

Scroll wheel zoom handler.

tap

Mobile touch hacks (quick tap and touch hold) handler.

touchZoom

touchZoom: IHandler

Touch zoom handler.

zoomControl

zoomControl: Zoom

Zoom control.

Methods

addControl

  • Adds the given control to the map.

    Parameters

    Returns Map

addEventListener

  • addEventListener(type: string, fn: function, context?: any): Map
  • addEventListener(eventMap: any, context?: any): Map
  • Parameters

    Returns Map

  • Parameters

    • eventMap: any
    • Optional context: any

    Returns Map

addLayer

  • addLayer(layer: ILayer, insertAtTheBottom?: boolean): Map
  • 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

    • layer: ILayer
    • Optional insertAtTheBottom: boolean

    Returns Map

addOneTimeEventListener

  • addOneTimeEventListener(type: string, fn: function, context?: any): Map
  • Parameters

    Returns Map

clearAllEventListeners

  • clearAllEventListeners(): Map

closePopup

  • Closes the popup previously opened with openPopup (or the given one).

    Parameters

    Returns Map

containerPointToLatLng

  • Returns the geographical coordinates of a given map container point.

    Parameters

    Returns LatLng

containerPointToLayerPoint

  • Converts the point relative to the map container to a point relative to the map layer.

    Parameters

    Returns Point

fire

  • fire(type: string, data?: any): Map
  • Parameters

    • type: string
    • Optional data: any

    Returns Map

fireEvent

  • fireEvent(type: string, data?: any): Map
  • Parameters

    • type: string
    • Optional data: any

    Returns Map

fitBounds

  • Sets a map view that contains the given geographical bounds with the maximum zoom level possible.

    Parameters

    Returns Map

fitWorld

  • Sets a map view that mostly contains the whole world with the maximum zoom level possible.

    Parameters

    Returns Map

getBounds

  • Returns the LatLngBounds of the current map view.

    Returns LatLngBounds

getBoundsZoom

  • getBoundsZoom(bounds: LatLngBounds, inside?: boolean): number
  • 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

    Returns number

getCenter

  • Returns the geographical center of the map view.

    Returns LatLng

getContainer

  • getContainer(): HTMLElement
  • Returns the container element of the map.

    Returns HTMLElement

getMaxZoom

  • getMaxZoom(): number
  • Returns the maximum zoom level of the map.

    Returns number

getMinZoom

  • getMinZoom(): number
  • Returns the minimum zoom level of the map.

    Returns number

getPanes

  • Returns an object with different map panes (to render overlays in).

    Returns MapPanes

getPixelBounds

  • Returns the bounds of the current map view in projected pixel coordinates (sometimes useful in layer and overlay implementations).

    Returns Bounds

getPixelOrigin

  • getPixelOrigin(): Point
  • Returns the projected pixel coordinates of the top left point of the map layer (useful in custom layer and overlay implementations).

    Returns Point

getSize

  • Returns the current size of the map container.

    Returns Point

getZoom

  • getZoom(): number
  • Returns the current zoom of the map view.

    Returns number

hasEventListeners

  • hasEventListeners(type: string): boolean

hasLayer

  • hasLayer(layer: ILayer): boolean
  • Returns true if the given layer is currently added to the map.

    Parameters

    Returns boolean

invalidateSize

  • 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

  • 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

    • animate: boolean

    Returns Map

latLngToContainerPoint

  • Returns the map container point that corresponds to the given geographical coordinates.

    Parameters

    Returns Point

latLngToLayerPoint

  • Returns the map layer point that corresponds to the given geographical coordinates (useful for placing overlays on the map).

    Parameters

    Returns Point

layerPointToContainerPoint

  • Converts the point relative to the map layer to a point relative to the map container.

    Parameters

    Returns Point

layerPointToLatLng

  • Returns the geographical coordinates of a given map layer point.

    Parameters

    Returns LatLng

locate

  • 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

mouseEventToContainerPoint

  • Returns the pixel coordinates of a mouse click (relative to the top left corner of the map) given its event object.

    Parameters

    Returns Point

mouseEventToLatLng

  • Returns the geographical coordinates of the point the mouse clicked on given the click's event object.

    Parameters

    Returns LatLng

mouseEventToLayerPoint

  • Returns the pixel coordinates of a mouse click relative to the map layer given its event object.

    Parameters

    Returns Point

off

  • off(type: string, fn?: function, context?: any): Map
  • off(eventMap?: any, context?: any): Map
  • Parameters

    • type: string
    • Optional fn: function
    • Optional context: any

    Returns Map

  • Parameters

    • Optional eventMap: any
    • Optional context: any

    Returns Map

on

  • on(type: string, fn: function, context?: any): Map
  • on(eventMap: any, context?: any): Map
  • Parameters

    Returns Map

  • Parameters

    • eventMap: any
    • Optional context: any

    Returns Map

once

  • once(type: string, fn: function, context?: any): Map
  • Parameters

    Returns Map

openPopup

  • Opens the specified popup while closing the previously opened (to make sure only one is opened at one time for usability).

    Parameters

    Returns Map

  • Creates a popup with the specified options and opens it in the given point on a map.

    Parameters

    Returns Map

  • Creates a popup with the specified options and opens it in the given point on a map.

    Parameters

    Returns Map

panBy

  • Pans the map by a given number of pixels (animated).

    Parameters

    Returns Map

panInsideBounds

  • Pans the map to the closest view that would lie inside the given bounds (if it's not already).

    Parameters

    Returns Map

panTo

  • 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

project

  • Projects the given geographical coordinates to absolute pixel coordinates for the given zoom level (current zoom level by default).

    Parameters

    • latlng: LatLng
    • Optional zoom: number

    Returns Point

remove

  • remove(): Map
  • Destroys the map and clears all related event listeners.

    Returns Map

removeControl

  • Removes the given control from the map.

    Parameters

    Returns Map

removeEventListener

  • removeEventListener(type: string, fn?: function, context?: any): Map
  • removeEventListener(eventMap?: any, context?: any): Map
  • Parameters

    • type: string
    • Optional fn: function
    • Optional context: any

    Returns Map

  • Parameters

    • Optional eventMap: any
    • Optional context: any

    Returns Map

removeLayer

  • Removes the given layer from the map.

    Parameters

    Returns Map

setMaxBounds

  • 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

setView

  • Sets the view of the map (geographical center and zoom) with the given animation options.

    Parameters

    Returns Map

setZoom

  • Sets the zoom of the map.

    Parameters

    Returns Map

setZoomAround

  • 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

stopLocate

  • stopLocate(): Map
  • 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

unproject

  • Projects the given absolute pixel coordinates to geographical coordinates for the given zoom level (current zoom level by default).

    Parameters

    • point: Point
    • Optional zoom: number

    Returns LatLng

whenReady

  • whenReady(fn: function, context?: any): Map
  • 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: function
        • (map: Map): void
        • Parameters

          Returns void

    • Optional context: any

    Returns Map

zoomIn

  • Increases the zoom of the map by delta (1 by default).

    Parameters

    Returns Map

zoomOut

  • Decreases the zoom of the map by delta (1 by default).

    Parameters

    Returns Map

Static addInitHook

  • addInitHook(methodName: string, ...args: any[]): void
  • You can also use the following shortcut when you just need to make one additional method call.

    Parameters

    • methodName: string
    • Rest ...args: any[]

    Returns void

Static extend

  • You use L.Class.extend to define new classes, but you can use the same method on any class to inherit from it.

    Parameters

    Returns any