LeafletMap class

Inheritance
Annotations
  • @JS('L.map')

Constructors

LeafletMap(String id, [MapOptions? options])
Instantiates a map object given the DOM ID of a
LeafletMap.fromElement(Element e, [MapOptions? options])
Instantiates a map object given an instance of a

Properties

boxZoom ↔ Handler
Handlers //////
getter/setter pair
doubleClickZoom ↔ Handler
Double click zoom handler.
getter/setter pair
dragging ↔ Handler
Map dragging handler (by both mouse and touch).
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
keyboard ↔ Handler
Keyboard navigation handler.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
scrollWheelZoom ↔ Handler
Scroll wheel zoom handler.
getter/setter pair
tap ↔ Handler
Mobile touch hacks (quick tap and touch hold) handler.
getter/setter pair
touchZoom ↔ Handler
Touch zoom handler.
getter/setter pair

Methods

addControl(Control control) LeafletMap
Adds the given control to the map
addEventParent(Evented obj) Evented
Adds an event parent - an Evented that will receive propagated events
inherited
addHandler(String name, Function HandlerClass) LeafletMap
Adds a new Handler to the map, given its name and constructor function.
addLayer(Layer layer) LeafletMap
Adds the given layer to the map
closePopup([Popup? popup]) LeafletMap
Creates a popup with the specified content and options and opens it in the given point on a map. Closes the popup previously opened with openPopup (or the given one).
closeTooltip([Tooltip? tooltip]) LeafletMap
Creates a tooltip with the specified content and options and open it. Closes the tooltip given as parameter.
containerPointToLatLng(Point point) LatLng
Given a pixel coordinate relative to the map container, returns the corresponding geographical coordinate (for the current zoom level).
containerPointToLayerPoint(Point point) Point
Given a pixel coordinate relative to the map container, returns the corresponding pixel coordinate relative to the origin pixel.
createPane(String name, [Element? container]) Element
Creates a new map pane with the given name if it doesn't exist already, then returns it. The pane is created as a child of container, or as a child of the main map pane if not set.
distance(LatLng latlng1, LatLng latlng2) double
Returns the distance between two geographical coordinates according to the map's CRS. By default this measures distance in meters.
eachLayer(Function fn) LeafletMap
Iterates over the layers of the map, optionally specifying context of the iterator function
fire(String type, [dynamic data, bool? propagate]) Evented
Fires an event of the specified type. You can optionally provide an data object — the first argument of the listener function will contain its properties. The event can optionally be propagated to event parents.
inherited
fitBounds(LatLngBounds bounds, [FitBoundOptions? options]) LeafletMap
Zooms the map while keeping a specified pixel on the map (relative to the top-left corner) stationary. Sets a map view that contains the given geographical bounds with the maximum zoom level possible.
fitWorld([FitBoundOptions? options]) LeafletMap
Sets a map view that mostly contains the whole world with the maximum zoom level possible.
flyTo(LatLng latlng, [double? zoom, ZoomPanOptions? options]) LeafletMap
Sets the view of the map (geographical center and zoom) performing a smooth pan-zoom animation.
flyToBounds(LatLngBounds bounds, [FitBoundOptions? options]) LeafletMap
Sets the view of the map with a smooth animation like flyTo, but takes a bounds parameter like fitBounds.
getBounds() LatLngBounds
Returns the geographical bounds visible in the current map view
getBoundsZoom(LatLngBounds bounds, [bool? inside, Point? padding]) double
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.
getCenter() LatLng
Returns the geographical center of the map view
getContainer() Element
Returns the HTML element that contains the map.
getMaxZoom() double
Returns the maximum zoom level of the map (if set in the maxZoom option of the map or of any layers).
getMinZoom() double
Returns the minimum zoom level of the map (if set in the minZoom option of the map or of any layers), or 0 by default.
getPane(String pane) Element
Returns a map pane, given its name or its HTML element (its identity).
getPixelBounds() Bounds
Returns the bounds 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 top left point of the map layer (useful in custom layer and overlay implementations).
getPixelWorldBounds([double? zoom]) Bounds
Returns the world's bounds in pixel coordinates for zoom level zoom. If zoom is omitted, the map's current zoom level is used.
getRenderer(Path layer) Renderer
Methods Returns the instance of Renderer that should be used to render the given Path. It will ensure that the renderer options of the map and paths are respected, and that the renderers do exist on the map.
getScaleZoom(double scale, double fromZoom) double
Returns the zoom level that the map would end up at, if it is at fromZoom level and everything is scaled by a factor of scale. Inverse of getZoomScale.
getSize() Point
Returns the current size of the map container (in pixels).
getZoom() double
Returns the current zoom level of the map view
getZoomScale(double toZoom, double fromZoom) double
Returns the scale factor to be applied to a map transition from zoom level fromZoom to toZoom. Used internally to help with zoom animations.
hasLayer(Layer layer) bool
Returns true if the given layer is currently added to the map
invalidateSize([ZoomPanOptions? options]) LeafletMap
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. If options.debounceMoveend is true, it will delay moveend event so that it doesn't happen often even if the method is called many times in a row
latLngToContainerPoint(LatLng latlng) Point
Given a geographical coordinate, returns the corresponding pixel coordinate relative to the map container.
latLngToLayerPoint(LatLng latlng) Point
Given a geographical coordinate, returns the corresponding pixel coordinate relative to the origin pixel.
layerPointToContainerPoint(Point point) Point
Given a pixel coordinate relative to the origin pixel, returns the corresponding pixel coordinate relative to the map container.
layerPointToLatLng(Point point) LatLng
Given a pixel coordinate relative to the origin pixel, returns the corresponding geographical coordinate (for the current zoom level).
listens(String type) bool
Returns true if a particular event type has any listeners attached to it.
inherited
locate([LocateOptions? options]) LeafletMap
Tries to locate the user using the Geolocation API, firing a locationfound event with location data on success or a locationerror event on failure, and optionally sets the map view to the user's location with respect to detection accuracy (or to the world view if geolocation failed). Note that, if your page doesn't use HTTPS, this method will fail in modern browsers (Chrome 50 and newer) See Locate options for more details.
mouseEventToContainerPoint(MouseEvent ev) Point
Given a MouseEvent object, returns the pixel coordinate relative to the map container where the event took place.
mouseEventToLatLng(MouseEvent ev) LatLng
Given a MouseEvent object, returns geographical coordinate where the event took place.
mouseEventToLayerPoint(MouseEvent ev) Point
Given a MouseEvent object, returns the pixel coordinate relative to the origin pixel where the event took place.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
off(String type, [Function? fn, dynamic context]) Evented
Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to on, you must pass the same context to off in order to remove the listener.
inherited
on(String type, Function fn, [dynamic context]) LeafletMap
Adds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick').
override
once(String type, Function fn, [dynamic context]) Evented
Behaves as on(…), except the listener will only get fired once and then removed.
inherited
openPopup(Popup popup) LeafletMap
Opens the specified popup while closing the previously opened (to make sure only one is opened at one time for usability).
openTooltip(Tooltip tooltip) LeafletMap
Opens the specified tooltip.
panBy(Point offset, [PanOptions? options]) LeafletMap
Pans the map by a given number of pixels (animated).
panInside(LatLng latlng, [PanOptions? options]) LeafletMap
Pans the map the minimum amount to make the latlng visible. Use padding, paddingTopLeft and paddingTopRight options to fit the display to more restricted bounds, like fitBounds. If latlng is already within the (optionally padded) display bounds, the map will not be panned.
panInsideBounds(LatLngBounds bounds, [PanOptions? options]) LeafletMap
Pans the map to the closest view that would lie inside the given bounds (if it's not already), controlling the animation using the options specific, if any.
panTo(LatLng latlng, [PanOptions? options]) LeafletMap
Pans the map to a given center.
project(LatLng latlng, double zoom) Point
Projects a geographical coordinate LatLng according to the projection of the map's CRS, then scales it according to zoom and the CRS's Transformation. The result is pixel coordinate relative to the CRS origin.
remove() LeafletMap
Destroys the map and clears all related event listeners.
removeControl(Control control) LeafletMap
Removes the given control from the map
removeEventParent(Evented obj) Evented
Removes an event parent, so it will stop receiving propagated events
inherited
removeLayer(Layer layer) LeafletMap
Removes the given layer from the map.
setMaxBounds([Bounds? bounds]) LeafletMap
Restricts the map view to the given bounds (see the maxBounds option).
setMaxZoom(double zoom) LeafletMap
Sets the upper limit for the available zoom levels (see the maxZoom option).
setMinZoom(double zoom) LeafletMap
Sets the lower limit for the available zoom levels (see the minZoom option).
setView(LatLng center, double zoom, [ZoomPanOptions? options]) LeafletMap
Sets the view of the map (geographical center and zoom) with the given animation options.
setZoom(double zoom, [ZoomOptions? options]) LeafletMap
Sets the zoom of the map.
setZoomAround(LatLng latlng, double zoom, ZoomOptions options) LeafletMap
Zooms the map while keeping a specified geographical point on the map stationary (e.g. used internally for scroll zoom and double-click zoom).
stop() LeafletMap
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. Stops the currently running panTo or flyTo animation, if any.
stopLocate() LeafletMap
Stops watching location previously initiated by map.locate({watch: true}) and aborts resetting the map view if map.locate was called with {setView: true}.
toString() String
A string representation of this object.
inherited
unproject(Point point, double zoom) LatLng
Inverse of project.
whenReady(Function fn) LeafletMap
Runs the given function fn when the map gets initialized with a view (center and zoom) and at least one layer, or immediately if it's already initialized, optionally passing a function context.
wrapLatLng(LatLng latlng) LatLng
Returns a LatLng where lat and lng has been wrapped according to the map's CRS's wrapLat and wrapLng properties, if they are outside the CRS's bounds. By default this means longitude is wrapped around the dateline so its value is between -180 and +180 degrees.
wrapLatLngBounds(LatLngBounds bounds) LatLngBounds
Returns a LatLngBounds with the same size as the given one, ensuring that its center is within the CRS's bounds. By default this means the center longitude is wrapped around the dateline so its value is between -180 and +180 degrees, and the majority of the bounds overlaps the CRS's bounds.
zoomIn([double? delta, ZoomOptions? options]) LeafletMap
Increases the zoom of the map by delta (zoomDelta by default())
zoomOut([double? delta, ZoomOptions? options]) LeafletMap
Decreases the zoom of the map by delta (zoomDelta by default).

Operators

operator ==(Object other) bool
The equality operator.
inherited