leaflet
Version:
JavaScript library for mobile-friendly interactive maps
1,822 lines • 73.3 kB
TypeScript
import { Evented } from '../core/Events.js';
import { Point } from '../geometry/Point.js';
import { Bounds } from '../geometry/Bounds.js';
import { LatLng } from '../geo/LatLng.js';
import { LatLngBounds } from '../geo/LatLngBounds.js';
import { PosAnimation } from '../dom/PosAnimation.js';
import { AttributionControl } from '../control/AttributionControl.js';
import { ZoomControl } from '../control/ZoomControl.js';
import { Popup } from '../layer/Popup.js';
import { Tooltip } from '../layer/Tooltip.js';
import { BoxZoomHandler } from './handler/BoxZoomHandler.js';
import { DoubleClickZoomHandler } from './handler/DoubleClickZoomHandler.js';
import { DragHandler } from './handler/DragHandler.js';
import { KeyboardHandler } from './handler/KeyboardHandler.js';
import { ScrollWheelZoomHandler } from './handler/ScrollWheelZoomHandler.js';
import { TapHoldHandler } from './handler/TapHoldHandler.js';
import { PinchZoomHandler } from './handler/PinchZoomHandler.js';
import type { BoxZoomEvent, Defaults, DragEndEvent, ErrorEvent, FitBoundsOptions, InvalidateSizeOptions, LatLngBoundsExpression, LatLngExpression, LayerEvent, LayersControlEvent, LeafletEvent, LeafletKeyboardEvent, LeafletPointerEvent, LocateOptions, LocationEvent, MapDefaults, MapEventMap, MapOptions, MapPanes, PanInsideOptions, PanOptions, PointExpression, PopupEvent, PopupOptions, ResizeEvent, TooltipEvent, TooltipOptions, ViewPreResetEvent, WorldCopyJumpEvent, ZoomAnimEvent, ZoomOptions, ZoomPanOptions } from '../types.js';
import type { CRS } from '../geo/crs/CRS.js';
import type { Control } from '../control/Control.js';
import type { Handler } from '../core/Handler.js';
import type { Layer } from '../layer/Layer.js';
import type { LayerBase } from '../layer/LayerBase.js';
import type { GridLayer } from '../layer/tile/GridLayer.js';
import type { Path } from '../layer/vector/Path.js';
import type { Renderer } from '../layer/vector/Renderer.js';
declare const defaultOptions: {
/**
* The [Coordinate Reference System](#crs) to use. Don't change this if you're not sure what it means.
* @category Map State Options
* @type {typeof CRS}
*/
crs: typeof CRS;
/**
* Initial geographic center of the map
* @category Map State Options
* @type {LatLngExpression | undefined}
*/
center: LatLngExpression | undefined;
/**
* Initial map zoom level
* @category Map State Options
* @type {number | undefined}
*/
zoom: number | undefined;
/**
* Minimum zoom level of the map. If not specified and at least one `GridLayer` or `TileLayer`
* is in the map, the lowest of their `minZoom` options will be used instead.
* @category Map State Options
* @type {number | undefined}
*/
minZoom: number | undefined;
/**
* Maximum zoom level of the map. If not specified and at least one `GridLayer` or `TileLayer`
* is in the map, the highest of their `maxZoom` options will be used instead.
* @category Map State Options
* @type {number | undefined}
*/
maxZoom: number | undefined;
/**
* Array of layers that will be added to the map initially
* @category Map State Options
* @type {Layer[]}
*/
layers: Layer[];
/**
* When this option is set, the map restricts the view to the given geographical bounds,
* bouncing the user back if the user tries to pan outside the view. To set the restriction
* dynamically, use [`setMaxBounds`](#map-setmaxbounds) method.
* @category Map State Options
* @type {LatLngBoundsExpression | null}
*/
maxBounds: LatLngBoundsExpression | null;
/**
* The default method for drawing vector layers on the map. A new `SVG` renderer
* by default; pass `new Canvas()` to draw them on a canvas instead.
* @category Map State Options
* @type {Renderer | undefined}
*/
renderer: Renderer | undefined;
/**
* Whether the map zoom animation is enabled.
* @category Animation Options
*/
zoomAnimation: boolean;
/**
* Won't animate zoom if the zoom difference exceeds this value (or 1 if the user prefers
* [reduced motion](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/At-rules/@media/prefers-reduced-motion)
* and `animate: true` isn't passed).
* @category Animation Options
*/
zoomAnimationThreshold: number;
/**
* Whether the tile and popup fade animation is enabled.
* @category Animation Options
*/
fadeAnimation: boolean;
/**
* Whether markers animate their zoom with the zoom animation, if
* disabled they will disappear for the length of the animation.
* @category Animation Options
*/
markerZoomAnimation: boolean;
/**
* Defines the maximum size of a CSS translation transform. The default value should not be changed
* unless a web browser positions layers in the wrong place after doing a large `panBy`.
* @category Animation Options
*/
transform3DLimit: number;
/**
* Forces the map's zoom level to always be a multiple of this, particularly right after a
* [`fitBounds()`](#map-fitbounds) or a pinch-zoom. By default, the zoom level snaps to the
* nearest integer; lower values (e.g. `0.5` or `0.1`) allow for greater granularity. A value
* of `0` means the zoom level will not be snapped after `fitBounds` or a pinch-zoom.
* @category Interaction Options
*/
zoomSnap: number;
/**
* Controls how much the map's zoom level will change after a [`zoomIn()`](#map-zoomin),
* [`zoomOut()`](#map-zoomout), pressing `+` or `-` on the keyboard, or using the [zoom controls](#zoomcontrol).
* Values smaller than `1` (e.g. `0.5`) allow for greater granularity.
* @category Interaction Options
*/
zoomDelta: number;
/**
* Whether the map automatically handles browser window resize to update itself.
* @category Interaction Options
*/
trackResize: boolean;
/**
* Set it to `false` if you don't want popups to close when user clicks the map.
* @category Interaction Options
*/
closePopupOnClick: boolean;
/**
* Whether the map can be zoomed to a rectangular area specified
* by dragging the pointer while pressing the shift key.
* @category Interaction Options
*/
boxZoom: boolean;
/**
* Whether the map can be zoomed in by double clicking on it and zoomed out by
* double clicking while holding shift. If passed `'center'`, double-click zoom
* will zoom to the center of the view regardless of where the pointer was.
* @category Interaction Options
* @type {boolean | 'center'}
*/
doubleClickZoom: boolean | 'center';
/**
* Whether the map is draggable with pointer or not.
* @category Interaction Options
*/
dragging: boolean;
/**
* If enabled, panning of the map will have an inertia effect where the map builds
* momentum while dragging and continues moving in the same direction for some
* time. Feels especially nice on touch devices. Enabled by default.
* @category Panning Inertia Options
*/
inertia: boolean;
/**
* The rate with which the inertial movement slows down, in pixels/second².
* @category Panning Inertia Options
*/
inertiaDeceleration: number;
/**
* Max speed of the inertial movement, in pixels/second.
* @category Panning Inertia Options
*/
inertiaMaxSpeed: number;
/**
* The curvature factor of the inertial movement's easing, like the [`easeLinearity`](#panoptions-easelinearity)
* pan option.
* @category Panning Inertia Options
*/
easeLinearity: number;
/**
* With this option enabled, the map tracks when you pan to another "copy" of the world and seamlessly
* jumps to the original one so that all overlays like markers and vector layers are still visible. A
* map with an infinite CRS, such as `SimpleCRS`, does not jump, as it has no copies of the world.
* @category Panning Inertia Options
*/
worldCopyJump: boolean;
/**
* If `maxBounds` is set, this option will control how solid the bounds are when dragging
* the map around. The default value of `0.0` allows the user to drag outside the bounds at
* normal speed, higher values will slow down map dragging outside bounds, and `1.0` makes
* the bounds fully solid, preventing the user from dragging outside the bounds.
* @category Panning Inertia Options
*/
maxBoundsViscosity: number;
/**
* Makes the map focusable and allows users to navigate the map with keyboard arrows and `+`/`-` keys.
* @category Keyboard Navigation Options
*/
keyboard: boolean;
/**
* Amount of pixels to pan when pressing an arrow key.
* @category Keyboard Navigation Options
*/
keyboardPanDelta: number;
/**
* Sets the `aria-keyshortcuts` attribute of the map container. ARIA names keys by what they type
* on a given layout, so `true` uses the names for a US English layout, which can be wrong for pages
* in other languages; pass a string to set the value for your audience's layout instead.
* @category Keyboard Navigation Options
* @type {boolean | string}
*/
ariaKeyShortcuts: boolean | string;
/**
* Whether the map can be zoomed by using the mouse wheel. If passed `'center'`,
* it will zoom to the center of the view regardless of where the pointer was.
* @category Mouse wheel options
* @type {boolean | 'center'}
*/
scrollWheelZoom: boolean | 'center';
/**
* Limits the rate at which a wheel can fire (in milliseconds). By default,
* the user can't zoom via wheel more often than once per 40 ms.
* @category Mouse wheel options
*/
wheelDebounceTime: number;
/**
* How many scroll pixels (as reported by [DomEvent.getWheelDelta](#domevent-getwheeldelta)) mean a
* change of one full zoom level. Smaller values will make wheel-zooming faster (and vice versa).
* @category Mouse wheel options
*/
wheelPxPerZoomLevel: number;
/**
* Fires a `contextmenu` event on a long touch press. iOS Safari doesn't fire one natively.
* @category Touch interaction options
*/
tapHold: boolean;
/**
* The max number of pixels a user can shift his finger during touch for it to be considered a valid tap.
* @category Touch interaction options
*/
tapTolerance: number;
/**
* Whether the map can be zoomed by touch-dragging with two fingers. If passed `'center'`, it will zoom to the
* center of the view regardless of where the touch events (fingers) were. Enabled for touch-capable web
* browsers.
* @category Touch interaction options
* @type {boolean | 'center'}
*/
pinchZoom: boolean | 'center';
/**
* Set it to false if you don't want the map to zoom beyond min/max zoom and then bounce back when pinch-zooming.
* @category Touch interaction options
*/
bounceAtZoomLimits: boolean;
/**
* Whether a [zoom control](#zoomcontrol) is added to the map by default.
* @category Control options
*/
zoomControl: boolean;
/**
* Whether an [attribution control](#attributioncontrol) is added to the map by default.
* @category Control options
*/
attributionControl: boolean;
};
export type MapDefaultsValues = typeof defaultOptions;
export type DOMEventTarget = Evented<{
bubblingPointerEvents?: boolean;
bubblingMouseEvents?: boolean;
}> & {
getLatLng?(): LatLng;
_pxRadius?: number;
dragging?: {
enabled(): boolean;
moved(): unknown;
};
};
export type MapLayerEvents = {
/**
* Fired when the base layer is changed through the [layers control](#layerscontrol).
*/
baselayerchange: LayersControlEvent;
/**
* Fired when an overlay is selected through the [layers control](#layerscontrol).
*/
overlayadd: LayersControlEvent;
/**
* Fired when an overlay is deselected through the [layers control](#layerscontrol).
*/
overlayremove: LayersControlEvent;
/**
* Fired when a new layer is added to the map.
*/
layeradd: LayerEvent;
/**
* Fired when some layer is removed from the map
*/
layerremove: LayerEvent;
};
export type MapPopupEvents = {
/**
* Fired when a popup is opened in the map
*/
popupopen: PopupEvent;
/**
* Fired when a popup in the map is closed
*/
popupclose: PopupEvent;
/**
* Fired when the map starts autopanning when opening a popup.
*/
autopanstart: LeafletEvent;
};
export type MapTooltipEvents = {
/**
* Fired when a tooltip is opened in the map.
*/
tooltipopen: TooltipEvent;
/**
* Fired when a tooltip in the map is closed.
*/
tooltipclose: TooltipEvent;
};
export type MapStateEvents = {
/**
* Fired when the map is resized.
*/
resize: ResizeEvent;
/**
* Fired when the map is destroyed with [remove](#map-remove) method.
*/
unload: LeafletEvent;
/**
* Fired right before `viewreset`, while the map still has its old view, with the new center and zoom.
*/
viewprereset: ViewPreResetEvent;
/**
* Fired when the map needs to redraw its content (this usually happens on map zoom or load). Very useful for creating custom overlays.
*/
viewreset: LeafletEvent;
/**
* Fired when the map is initialized (when its center and zoom are set for the first time).
*/
load: LeafletEvent;
/**
* Fired when the map zoom is about to change (e.g. before zoom animation).
*/
zoomstart: LeafletEvent;
/**
* Fired when the view of the map starts changing (e.g. user starts dragging the map).
*/
movestart: LeafletEvent;
/**
* Fired repeatedly during any change in zoom level, including zoom and fly animations.
*/
zoom: LeafletEvent;
/**
* Fired repeatedly during any movement of the map, including pan and fly animations.
*/
move: LeafletEvent;
/**
* Fired when the map zoom changed, after any animations.
*/
zoomend: LeafletEvent;
/**
* Fired when the center of the map stops changing (e.g. user stopped dragging the map or after non-centered zoom).
*/
moveend: LeafletEvent;
/**
* Fired when [`worldCopyJump`](#map-worldcopyjump) moves the map pane by one or more world widths.
*/
worldcopyjump: WorldCopyJumpEvent;
/**
* Fired when the number of zoomlevels on the map is changed due to adding or removing a layer.
*/
zoomlevelschange: LeafletEvent;
};
export type MapLocationEvents = {
/**
* Fired when geolocation (using the [`locate`](#map-locate) method) failed.
*/
locationerror: ErrorEvent;
/**
* Fired when geolocation (using the [`locate`](#map-locate) method) went successfully.
*/
locationfound: LocationEvent;
};
export type MapInteractionEvents = {
/**
* Fired when the user clicks (or taps) the map.
*/
click: LeafletPointerEvent;
/**
* Fired when the user double-clicks (or double-taps) the map.
*/
dblclick: LeafletPointerEvent;
/**
* Fired when the user pushes the pointer on the map.
*/
pointerdown: LeafletPointerEvent;
/**
* Fired when the user releases the pointer on the map.
*/
pointerup: LeafletPointerEvent;
/**
* Fired when the pointer enters the map.
*/
pointerover: LeafletPointerEvent;
/**
* Fired when the pointer leaves the map.
*/
pointerout: LeafletPointerEvent;
/**
* Fired while the pointer moves over the map.
*/
pointermove: LeafletPointerEvent;
/**
* Fired when the user pushes the right mouse button on the map, prevents default browser context menu from showing if there are listeners on this event. Also fired on mobile when the user holds a single touch for a second (also called long press).
*/
contextmenu: LeafletPointerEvent;
/**
* Fired when the user presses a key from the keyboard while the map is focused.
*/
keydown: LeafletKeyboardEvent;
/**
* Fired when the user releases a key from the keyboard while the map is focused.
*/
keyup: LeafletKeyboardEvent;
/**
* Fired before pointer click on the map (sometimes useful when you want something to happen on click before any existing click handlers start running).
*/
preclick: LeafletPointerEvent;
};
export type MapHandlerEvents = {
/**
* Fired when the user starts dragging the map.
*/
dragstart: LeafletEvent;
/**
* Fired repeatedly while the user drags the map.
*/
drag: LeafletEvent;
/**
* Fired when the user stops dragging the map.
*/
dragend: DragEndEvent;
/**
* Fired when the user starts drawing a [box zoom](#map-boxzoom) rectangle.
*/
boxzoomstart: LeafletEvent;
/**
* Fired when the user finishes a box zoom, before the map zooms to the box.
*/
boxzoomend: BoxZoomEvent;
/**
* Fired when the map container gets focus (with [`keyboard`](#map-keyboard) on).
*/
focus: LeafletEvent;
/**
* Fired when the map container loses focus (with [`keyboard`](#map-keyboard) on).
*/
blur: LeafletEvent;
};
export type MapOtherEvents = {
/**
* Fired at least once per zoom animation. For continuous zoom, like pinch zooming, fired once per frame during zoom.
*/
zoomanim: ZoomAnimEvent;
};
export type ZoomProps = {
/**
* If not specified, zoom animation will happen if the zoom origin is inside
* the current view, and if the user prefers reduced motion, only when zooming by at most one level. If
* `true`, the map will attempt animating zoom disregarding where zoom origin is and the user's reduced
* motion preference. Setting `false` will make it always reset the view completely without animation.
*/
animate?: boolean;
};
export type PanProps = {
/**
* If `true`, panning will always be animated if possible, even if
* the user prefers reduced motion. If `false`, it will not animate panning, either resetting
* the map view if panning more than a screen away, or just setting a new offset for the map
* pane (except for `panBy` which always does the latter). If not specified, panning is
* animated, except for pans longer than half the map size when the user prefers reduced motion.
*/
animate?: boolean;
/**
* Duration of animated panning, in seconds.
*/
duration?: number;
/**
* The curvature factor of panning animation easing
* (third parameter of the [Cubic Bezier curve](https://cubic-bezier.com/)). 1.0 means linear
* animation, and the smaller this number, the more bowed the curve.
*/
easeLinearity?: number;
/**
* If `true`, panning won't fire `movestart` event on
* start (used internally for panning inertia).
*/
noMoveStart?: boolean;
};
export type ZoomPanProps = {
/**
* If `true`, the view is reset without animation.
*/
reset?: boolean;
/**
* Options for the zoom part of the change, taking precedence over `animate`.
*/
zoom?: ZoomOptions;
/**
* Options for the pan part of the change, taking precedence over
* `animate` and `duration`.
*/
pan?: PanOptions;
};
export type InvalidateSizeProps = {
/**
* If `false`, panning will not occur.
*/
pan?: boolean;
/**
* If `true`, it will delay `moveend` event so that
* it doesn't happen often even if the method is called many times in a row.
*/
debounceMoveend?: boolean;
};
export type PaddingProps = {
/**
* Sets the amount of padding in the top left corner of a
* map container that shouldn't be accounted for when setting the view to fit bounds. Useful if you have some
* control overlays on the map like a sidebar and you don't want them to obscure objects you're zooming to.
*/
paddingTopLeft?: PointExpression;
/**
* The same for the bottom right corner of the map.
*/
paddingBottomRight?: PointExpression;
/**
* Equivalent of setting both top left and bottom
* right padding to the same value.
*/
padding?: PointExpression;
};
export type FitBoundsProps = {
/**
* The maximum possible zoom to use.
*/
maxZoom?: number;
};
export type LocateProps = {
/**
* If `true`, starts continuous watching of location changes (instead of detecting
* it once) using W3C `watchPosition` method. You can later stop watching using `map.stopLocate()` method.
*/
watch?: boolean;
/**
* If `true`, automatically sets the map view to the user
* location with respect to detection accuracy, or to world view if geolocation failed.
*/
setView?: boolean;
/**
* The maximum zoom for automatic view setting when using `setView` option.
*/
maxZoom?: number;
/**
* Number of milliseconds to wait for a response from
* geolocation before firing a `locationerror` event.
*/
timeout?: number;
/**
* Maximum age of detected location. If less than this amount of
* milliseconds passed since last geolocation response, `locate` will return a cached location.
*/
maximumAge?: number;
/**
* Enables high accuracy, see [description in
* the W3C spec](https://w3c.github.io/geolocation-api/#enablehighaccuracy-member).
*/
enableHighAccuracy?: boolean;
};
export type LeafletKeyboardEventProps = {
/**
* The original
* [DOM `KeyboardEvent`](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent) that triggered this event.
*/
originalEvent: KeyboardEvent;
};
export type LeafletPointerEventProps = {
/**
* The geographical point where the pointer event occurred.
*/
latlng: LatLng;
/**
* Pixel coordinates of the point where the pointer event
* occurred relative to the map layer.
*/
layerPoint: Point;
/**
* Pixel coordinates of the point where the pointer event
* occurred relative to the map container.
*/
containerPoint: Point;
/**
* The original
* [DOM `MouseEvent`](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent) or
* [DOM `PointerEvent`](https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent) that triggered this event.
*/
originalEvent: PointerEvent | MouseEvent;
};
export type LocationEventProps = {
/**
* Detected geographical location of the user.
*/
latlng: LatLng;
/**
* Geographical bounds of the area user is located in (with
* respect to the accuracy of location).
*/
bounds: LatLngBounds;
/**
* Accuracy of location in meters.
*/
accuracy: number;
/**
* Height of the position above the WGS84 ellipsoid in meters.
*/
altitude: number | null;
/**
* Accuracy of altitude in meters.
*/
altitudeAccuracy: number | null;
/**
* The direction of travel in degrees counting clockwise from true North.
*/
heading: number | null;
/**
* Current velocity in meters per second.
*/
speed: number | null;
/**
* The time when the position was acquired.
*/
timestamp: number;
};
export type ErrorEventProps = {
/**
* Error message.
*/
message: string;
/**
* Error code (if applicable).
*/
code: number;
};
export type LayerEventProps = {
/**
* The layer that was added or removed.
*/
layer: Layer;
};
export type ResizeEventProps = {
/**
* The old size before resize event.
*/
oldSize: Point;
/**
* The new size after the resize event.
*/
newSize: Point;
};
export type ZoomAnimEventProps = {
/**
* The current center of the map.
*/
center: LatLng;
/**
* The current zoom level of the map.
*/
zoom: number;
/**
* Whether layers should update their contents due to this event.
*/
noUpdate: boolean;
};
export type ViewPreResetEventProps = {
/**
* The center of the new view.
*/
center: LatLng;
/**
* The zoom level of the new view.
*/
zoom: number;
};
export type WorldCopyJumpEventProps = {
/**
* The signed number of world widths by which the map pane moved.
*/
worlds: number;
};
/** @typedef {typeof defaultOptions} MapDefaultsValues */
/**
* The map or a layer receiving DOM events, duck-typed for markers.
* @typedef {Evented<{bubblingPointerEvents?: boolean, bubblingMouseEvents?: boolean}> & {getLatLng?(): LatLng,
* _pxRadius?: number, dragging?: {enabled(): boolean, moved(): unknown}}} DOMEventTarget
*/
/**
* @category Layer events
* @typedef {Object} MapLayerEvents
* @property {LayersControlEvent} baselayerchange Fired when the base layer is changed through the [layers control](#layerscontrol).
* @property {LayersControlEvent} overlayadd Fired when an overlay is selected through the [layers control](#layerscontrol).
* @property {LayersControlEvent} overlayremove Fired when an overlay is deselected through the [layers control](#layerscontrol).
* @property {LayerEvent} layeradd Fired when a new layer is added to the map.
* @property {LayerEvent} layerremove Fired when some layer is removed from the map
*/
/**
* @category Popup events
* @typedef {Object} MapPopupEvents
* @property {PopupEvent} popupopen Fired when a popup is opened in the map
* @property {PopupEvent} popupclose Fired when a popup in the map is closed
* @property {LeafletEvent} autopanstart Fired when the map starts autopanning when opening a popup.
*/
/**
* @category Tooltip events
* @typedef {Object} MapTooltipEvents
* @property {TooltipEvent} tooltipopen Fired when a tooltip is opened in the map.
* @property {TooltipEvent} tooltipclose Fired when a tooltip in the map is closed.
*/
/**
* @category Map state change events
* @typedef {Object} MapStateEvents
* @property {ResizeEvent} resize Fired when the map is resized.
* @property {LeafletEvent} unload Fired when the map is destroyed with [remove](#map-remove) method.
* @property {ViewPreResetEvent} viewprereset Fired right before `viewreset`, while the map still has its old view, with the new center and zoom.
* @property {LeafletEvent} viewreset Fired when the map needs to redraw its content (this usually happens on map zoom or load). Very useful for creating custom overlays.
* @property {LeafletEvent} load Fired when the map is initialized (when its center and zoom are set for the first time).
* @property {LeafletEvent} zoomstart Fired when the map zoom is about to change (e.g. before zoom animation).
* @property {LeafletEvent} movestart Fired when the view of the map starts changing (e.g. user starts dragging the map).
* @property {LeafletEvent} zoom Fired repeatedly during any change in zoom level, including zoom and fly animations.
* @property {LeafletEvent} move Fired repeatedly during any movement of the map, including pan and fly animations.
* @property {LeafletEvent} zoomend Fired when the map zoom changed, after any animations.
* @property {LeafletEvent} moveend Fired when the center of the map stops changing (e.g. user stopped dragging the map or after non-centered zoom).
* @property {WorldCopyJumpEvent} worldcopyjump Fired when [`worldCopyJump`](#map-worldcopyjump) moves the map pane by one or more world widths.
* @property {LeafletEvent} zoomlevelschange Fired when the number of zoomlevels on the map is changed due to adding or removing a layer.
*/
/**
* @category Location events
* @typedef {Object} MapLocationEvents
* @property {ErrorEvent} locationerror Fired when geolocation (using the [`locate`](#map-locate) method) failed.
* @property {LocationEvent} locationfound Fired when geolocation (using the [`locate`](#map-locate) method) went successfully.
*/
/**
* @category Interaction events
* @typedef {Object} MapInteractionEvents
* @property {LeafletPointerEvent} click Fired when the user clicks (or taps) the map.
* @property {LeafletPointerEvent} dblclick Fired when the user double-clicks (or double-taps) the map.
* @property {LeafletPointerEvent} pointerdown Fired when the user pushes the pointer on the map.
* @property {LeafletPointerEvent} pointerup Fired when the user releases the pointer on the map.
* @property {LeafletPointerEvent} pointerover Fired when the pointer enters the map.
* @property {LeafletPointerEvent} pointerout Fired when the pointer leaves the map.
* @property {LeafletPointerEvent} pointermove Fired while the pointer moves over the map.
* @property {LeafletPointerEvent} contextmenu Fired when the user pushes the right mouse button on the map, prevents default browser context menu from showing if there are listeners on this event. Also fired on mobile when the user holds a single touch for a second (also called long press).
* @property {LeafletKeyboardEvent} keydown Fired when the user presses a key from the keyboard while the map is focused.
* @property {LeafletKeyboardEvent} keyup Fired when the user releases a key from the keyboard while the map is focused.
* @property {LeafletPointerEvent} preclick Fired before pointer click on the map (sometimes useful when you want something to happen on click before any existing click handlers start running).
*/
/**
* @category Interaction Handler Events
* @typedef {Object} MapHandlerEvents
* @property {LeafletEvent} dragstart Fired when the user starts dragging the map.
* @property {LeafletEvent} drag Fired repeatedly while the user drags the map.
* @property {DragEndEvent} dragend Fired when the user stops dragging the map.
* @property {LeafletEvent} boxzoomstart Fired when the user starts drawing a [box zoom](#map-boxzoom) rectangle.
* @property {BoxZoomEvent} boxzoomend Fired when the user finishes a box zoom, before the map zooms to the box.
* @property {LeafletEvent} focus Fired when the map container gets focus (with [`keyboard`](#map-keyboard) on).
* @property {LeafletEvent} blur Fired when the map container loses focus (with [`keyboard`](#map-keyboard) on).
*/
/**
* @category Other Events
* @typedef {Object} MapOtherEvents
* @property {ZoomAnimEvent} zoomanim Fired at least once per zoom animation. For continuous zoom, like pinch zooming, fired once per frame during zoom.
*/
/**
* @typedef {Object} ZoomProps
* @property {boolean} [animate] If not specified, zoom animation will happen if the zoom origin is inside
* the current view, and if the user prefers reduced motion, only when zooming by at most one level. If
* `true`, the map will attempt animating zoom disregarding where zoom origin is and the user's reduced
* motion preference. Setting `false` will make it always reset the view completely without animation.
*/
/**
* @typedef {Object} PanProps
* @property {boolean} [animate] If `true`, panning will always be animated if possible, even if
* the user prefers reduced motion. If `false`, it will not animate panning, either resetting
* the map view if panning more than a screen away, or just setting a new offset for the map
* pane (except for `panBy` which always does the latter). If not specified, panning is
* animated, except for pans longer than half the map size when the user prefers reduced motion.
* @property {number} [duration=0.25] Duration of animated panning, in seconds.
* @property {number} [easeLinearity=0.25] The curvature factor of panning animation easing
* (third parameter of the [Cubic Bezier curve](https://cubic-bezier.com/)). 1.0 means linear
* animation, and the smaller this number, the more bowed the curve.
* @property {boolean} [noMoveStart=false] If `true`, panning won't fire `movestart` event on
* start (used internally for panning inertia).
*/
/**
* @typedef {Object} ZoomPanProps
* @property {boolean} [reset] If `true`, the view is reset without animation.
* @property {ZoomOptions} [zoom] Options for the zoom part of the change, taking precedence over `animate`.
* @property {PanOptions} [pan] Options for the pan part of the change, taking precedence over
* `animate` and `duration`.
*/
/**
* @typedef {Object} InvalidateSizeProps
* @property {boolean} [pan=true] If `false`, panning will not occur.
* @property {boolean} [debounceMoveend=false] If `true`, it will delay `moveend` event so that
* it doesn't happen often even if the method is called many times in a row.
*/
/**
* @typedef {Object} PaddingProps
* @property {PointExpression} [paddingTopLeft=[0, 0]] Sets the amount of padding in the top left corner of a
* map container that shouldn't be accounted for when setting the view to fit bounds. Useful if you have some
* control overlays on the map like a sidebar and you don't want them to obscure objects you're zooming to.
* @property {PointExpression} [paddingBottomRight=[0, 0]] The same for the bottom right corner of the map.
* @property {PointExpression} [padding=[0, 0]] Equivalent of setting both top left and bottom
* right padding to the same value.
*/
/**
* @typedef {Object} FitBoundsProps
* @property {number} [maxZoom] The maximum possible zoom to use.
*/
/**
* @typedef {Object} LocateProps
* @property {boolean} [watch=false] If `true`, starts continuous watching of location changes (instead of detecting
* it once) using W3C `watchPosition` method. You can later stop watching using `map.stopLocate()` method.
* @property {boolean} [setView=false] If `true`, automatically sets the map view to the user
* location with respect to detection accuracy, or to world view if geolocation failed.
* @property {number} [maxZoom=Infinity] The maximum zoom for automatic view setting when using `setView` option.
* @property {number} [timeout=10000] Number of milliseconds to wait for a response from
* geolocation before firing a `locationerror` event.
* @property {number} [maximumAge=0] Maximum age of detected location. If less than this amount of
* milliseconds passed since last geolocation response, `locate` will return a cached location.
* @property {boolean} [enableHighAccuracy=false] Enables high accuracy, see [description in
* the W3C spec](https://w3c.github.io/geolocation-api/#enablehighaccuracy-member).
*/
/**
* @typedef {Object} LeafletKeyboardEventProps
* @property {KeyboardEvent} originalEvent The original
* [DOM `KeyboardEvent`](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent) that triggered this event.
*/
/**
* @typedef {Object} LeafletPointerEventProps
* @property {LatLng} latlng The geographical point where the pointer event occurred.
* @property {Point} layerPoint Pixel coordinates of the point where the pointer event
* occurred relative to the map layer.
* @property {Point} containerPoint Pixel coordinates of the point where the pointer event
* occurred relative to the map container.
* @property {PointerEvent | MouseEvent} originalEvent The original
* [DOM `MouseEvent`](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent) or
* [DOM `PointerEvent`](https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent) that triggered this event.
*/
/**
* @typedef {Object} LocationEventProps
* @property {LatLng} latlng Detected geographical location of the user.
* @property {LatLngBounds} bounds Geographical bounds of the area user is located in (with
* respect to the accuracy of location).
* @property {number} accuracy Accuracy of location in meters.
* @property {number | null} altitude Height of the position above the WGS84 ellipsoid in meters.
* @property {number | null} altitudeAccuracy Accuracy of altitude in meters.
* @property {number | null} heading The direction of travel in degrees counting clockwise from true North.
* @property {number | null} speed Current velocity in meters per second.
* @property {number} timestamp The time when the position was acquired.
*/
/**
* @typedef {Object} ErrorEventProps
* @property {string} message Error message.
* @property {number} code Error code (if applicable).
*/
/**
* @typedef {Object} LayerEventProps
* @property {Layer} layer The layer that was added or removed.
*/
/**
* @typedef {Object} ResizeEventProps
* @property {Point} oldSize The old size before resize event.
* @property {Point} newSize The new size after the resize event.
*/
/**
* @typedef {Object} ZoomAnimEventProps
* @property {LatLng} center The current center of the map.
* @property {number} zoom The current zoom level of the map.
* @property {boolean} noUpdate Whether layers should update their contents due to this event.
*/
/**
* @typedef {Object} ViewPreResetEventProps
* @property {LatLng} center The center of the new view.
* @property {number} zoom The zoom level of the new view.
*/
/**
* @typedef {Object} WorldCopyJumpEventProps
* @property {number} worlds The signed number of world widths by which the map pane moved.
*/
/**
* The central class of the API — it is used to create a map on a page and manipulate it.
* @example
* ```js
* // initialize the map on the "map" div with a given center and zoom
* const map = new LeafletMap('map', {
* center: [51.505, -0.09],
* zoom: 13
* });
* ```
*
* @categoryDescription Handlers
* Map properties include interaction handlers that allow you to control interaction behavior in runtime,
* enabling or disabling certain features such as dragging or touch zoom (see `Handler` methods). For example:
*
* ```js
* map.doubleClickZoom.disable();
* ```
* @categoryDescription Map panes
* Panes are DOM elements used to control the ordering of layers on the map. You can access panes with
* [`map.getPane`](#map-getpane) or [`map.getPanes`](#map-getpanes) methods. New panes can be created with the
* [`map.createPane`](#map-createpane) method.
*
* Every map has the following default panes that differ only in z-index.
* @extends {Evented<MapOptions & MapDefaults, MapEventMap>}
*/
export declare class LeafletMap extends Evented<MapOptions & MapDefaults, MapEventMap> {
/** @type {Handler[]} */
_handlers: Handler[];
/** @type {{[id: number]: LayerBase}} */
_layers: {
[id: number]: LayerBase;
};
/** @type {{[id: number]: GridLayer}} */
_zoomBoundLayers: {
[id: number]: GridLayer;
};
_sizeChanged: boolean;
/** @type {Popup | undefined} */
_popup: Popup | undefined;
/** @type {Renderer | undefined} */
_renderer: Renderer | undefined;
/** @type {number} */
_zoom: number;
/**
* The attribution control (only available if the
* [`attributionControl` option](#map-attributioncontrol) was `true` when creating the map).
* @category Controls
* @type {AttributionControl | undefined}
*/
attributionControl: AttributionControl | undefined;
/**
* The default zoom control (only available if the
* [`zoomControl` option](#map-zoomcontrol) was `true` when creating the map).
* @category Controls
* @type {ZoomControl | undefined}
*/
zoomControl: ZoomControl | undefined;
/**
* Box (shift-drag with pointer) zoom handler.
* @category Handlers
* @type {BoxZoomHandler}
*/
boxZoom: BoxZoomHandler;
/**
* Double click zoom handler.
* @category Handlers
* @type {DoubleClickZoomHandler}
*/
doubleClickZoom: DoubleClickZoomHandler;
/**
* Map dragging handler.
* @category Handlers
* @type {DragHandler}
*/
dragging: DragHandler;
/**
* Keyboard navigation handler.
* @category Handlers
* @type {KeyboardHandler}
*/
keyboard: KeyboardHandler;
/**
* Scroll wheel zoom handler.
* @category Handlers
* @type {ScrollWheelZoomHandler}
*/
scrollWheelZoom: ScrollWheelZoomHandler;
/**
* Long tap handler to simulate `contextmenu` event (useful in mobile Safari).
* @category Handlers
* @type {TapHoldHandler}
*/
tapHold: TapHoldHandler;
/**
* Pinch zoom handler.
* @category Handlers
* @type {PinchZoomHandler}
*/
pinchZoom: PinchZoomHandler;
/** @deprecated Use `pinchZoom`. */
touchZoom: PinchZoomHandler;
_zoomAnimated: boolean;
_panAnim: PosAnimation | undefined;
/** @type {number} */
_flyToFrame: number;
_enforcingBounds: boolean | undefined;
_lastCenter: LatLng | null;
_sizeTimer: number | undefined;
/** @type {LocateOptions} */
_locateOptions: LocateOptions;
/** @type {number} */
_locationWatchId: number;
_controlCorners: {
[position: string]: HTMLElement;
};
_panes: MapPanes;
/** @type {Point} */
_size: Point;
/** @type {HTMLElement & {_leaflet_id?: number}} */
_container: HTMLElement & {
_leaflet_id?: number;
};
_containerId: number | undefined;
_fadeAnimated: boolean | undefined;
/** @type {HTMLElement} */
_controlContainer: HTMLElement;
/** @type {{[pane: string]: Renderer}} */
_paneRenderers: {
[pane: string]: Renderer;
};
/** @type {HTMLElement} */
_mapPane: HTMLElement;
_loaded: boolean | undefined;
/** @type {number} */
_instantZoomEnd: number;
/** @type {Point} */
_lastCenterPanePos: Point;
/** @type {Point} */
_pixelOrigin: Point;
_layersMaxZoom: number | undefined;
_layersMinZoom: number | undefined;
/** @type {{[id: number]: DOMEventTarget}} */
_targets: {
[id: number]: DOMEventTarget;
};
/** @type {ResizeObserver} */
_resizeObserver: ResizeObserver;
/** @type {number} */
_resizeRequest: number;
/** @type {HTMLElement} */
_proxy: HTMLElement;
/** @type {number} */
_zoomAnimFrame: number;
_animatingZoom: boolean | undefined;
/** @type {LatLng} */
_animateToCenter: LatLng;
/** @type {number} */
_animateToZoom: number;
_tempFireZoomEvent: boolean | undefined;
_transitionEndTimer: number | undefined;
static initHooks: boolean;
/** @type {Defaults<MapOptions>} */
static defaultOptions: Defaults<MapOptions>;
/**
* Instantiates a map object given the DOM ID of a `<div>` element (or the element itself)
* and optionally an object literal with `Map options`. Sets `role="region"` and `aria-label="Map"` on the
* container unless already present.
* @param {string | HTMLElement} id
* @param {Partial<MapOptions>} [options]
*/
constructor(id: string | HTMLElement, options?: Partial<MapOptions>);
/**
* Sets the view of the map (geographical center and zoom) with the given animation options.
* @category Methods for modifying map state
* @param {LatLngExpression} center
* @param {number} [zoom]
* @param {ZoomPanOptions} [options]
*/
setView(center: LatLngExpression, zoom?: number, options?: ZoomPanOptions): this;
/**
* Sets the zoom of the map.
* @category Methods for modifying map state
* @param {number} zoom
* @param {ZoomOptions} [options]
*/
setZoom(zoom: number, options?: ZoomOptions): this;
/**
* Increases the zoom of the map by `delta` ([`zoomDelta`](#map-zoomdelta) by default).
* @category Methods for modifying map state
* @param {number} [delta]
* @param {ZoomOptions} [options]
*/
zoomIn(delta?: number, options?: ZoomOptions): this;
/**
* Decreases the zoom of the map by `delta` ([`zoomDelta`](#map-zoomdelta) by default).
* @category Methods for modifying map state
* @param {number} [delta]
* @param {ZoomOptions} [options]
*/
zoomOut(delta?: number, options?: ZoomOptions): this;
/**
* Zooms the map while keeping a specified geographical point on the map stationary
* (e.g. used internally for scroll zoom and double-click zoom).
* @category Methods for modifying map state
* @overload
* @param {LatLngExpression} latlng
* @param {number} zoom
* @param {ZoomOptions} [options]
* @returns {this}
*/
/**
* Zooms the map while keeping a specified pixel on the map (relative to the top-left corner) stationary.
* @overload
* @param {Point} offset
* @param {number} zoom
* @param {ZoomOptions} [options]
* @returns {this}
*/
/**
* @param {LatLngExpression | Point} latlng
* @param {number} zoom
* @param {ZoomOptions} [options]
*/
setZoomAround(latlng: LatLngExpression, zoom: number, options?: ZoomOptions): this;
/**
* Zooms the map while keeping a specified geographical point on the map stationary
* (e.g. used internally for scroll zoom and double-click zoom).
* @category Methods for modifying map state
* @overload
* @param {LatLngExpression} latlng
* @param {number} zoom
* @param {ZoomOptions} [options]
* @returns {this}
*/
/**
* Zooms the map while keeping a specified pixel on the map (relative to the top-left corner) stationary.
* @overload
* @param {Point} offset
* @param {number} zoom
* @param {ZoomOptions} [options]
* @returns {this}
*/
/**
* @param {LatLngExpression | Point} latlng
* @param {number} zoom
* @param {ZoomOptions} [options]
*/
setZoomAround(offset: Point, zoom: number, options?: ZoomOptions): this;
/**
* @param {LatLngBoundsExpression | {getBounds(): LatLngBounds}} bounds
* @param {FitBoundsOptions} [options]
*/
_getBoundsCenterZoom(bounds: LatLngBoundsExpression | {
getBounds(): LatLngBounds;
}, options?: FitBoundsOptions): {
center: LatLng;
zoom: number;
};
/**
* Sets a map view that contains the given geographical bounds with the maximum zoom level possible.
* @category Methods for modifying map state
* @param {LatLngBoundsExpression} bounds
* @param {FitBoundsOptions} [options]
*/
fitBounds(bounds: LatLngBoundsExpression, options?: FitBoundsOptions): this;
/**
* Sets a map view that mostly contains the whole world with the maximum zoom level possible.
* @category Methods for modifying map state
* @param {FitBoundsOptions} [options]
*/
fitWorld(options?: FitBoundsOptions): this;
/**
* Pans the map to a given center.
* @category Methods for modifying map state
* @param {LatLngExpression} center
* @param {PanOptions} [options]
*/
panTo(center: LatLngExpression, options?: PanOptions): this;
/**
* Pans the map by a given number of pixels (animated unless `animate: false` is passed, or the user
* prefers reduced motion and the pan is longer than half the map size without `animate: true`).
* @category Methods for modifying map state
* @param {PointExpression} offset
* @param {PanOptions} [options]
*/
panBy(offset: PointExpression, options?: PanOptions): this;
/**
* Sets the view of the map (geographical center and zoom) performing a smooth pan-zoom
* animation. If the user prefers reduced motion (and `animate: true` isn't passed),
* it behaves like `setView` instead, only animating short pans and zooms.
* @category Methods for modifying map state
* @param {LatLngExpression} targetCenter
* @param {number} [targetZoom]
* @param {ZoomPanOptions} [options]
*/
flyTo(targetCenter: LatLngExpression, targetZoom?: number, options?: ZoomPanOptions): this;
/**
* Sets the view of the map with a smooth animation like [`flyTo`](#map-flyto),
* but takes a bounds parameter like [`fitBounds`](#map-fitbounds), or anything with a `getBounds()` method, like a
* `FeatureGroup`.
* @category Methods for modifying map state
* @param {LatLngBoundsExpression | {getBounds(): LatLngBounds}} bounds
* @param {FitBoundsOptions} [options]
*/
flyToBounds(bounds: LatLngBoundsExpression | {
getBounds(): LatLngBounds;
}, options?: FitBoundsOptions): this;
/**
* Restricts the map view to the given bounds (see the [maxBounds](#map-maxbounds) option).
* Call it without arguments to remove the restriction.
* @category Methods for modifying map state
* @param {LatLngBoundsExpression} [bounds]
*/
setMaxBounds(bounds?: LatLngBoundsExpression): this;
/**
* Sets the lower limit for the available zoom levels (see the [minZoom](#map-minzoom) option).
* @category Methods for modifying map state
* @param {number} zoom
*/
setMinZoom(zoom: number): this;
/**
* Sets the upper limit for the available zoom levels (see the [maxZoom](#map-maxzoom) option).
* @category Methods for modifying map state
* @param {number} zoom
*/
setMaxZoom(zoom: number): this;
/**
* 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.
* @category Methods for modifying map state
* @param {LatLngBoundsExpression} bounds
* @param {PanOptions} [options]
*/
panInsideBounds(bounds: LatLngBoundsExpression, options?: PanOptions): this;
/**
* Pans the map the minimum amount to make the `latlng` visible. Use padding options
* to fit the display to more restricted bounds. If `latlng` is already within
* the (optionally padded) display bounds, the map will not be panned.
* @category Methods for modifying map state
* @param {LatLngExpression} latlng
* @param {PanInsideOptions} [options]
*/
panInside(latlng: LatLngExpression, options?: PanInsideOptions): this;
/**
* 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. `true` is a shorthand
* for `{animate: true}`.
* @category Methods for modifying map state
* @param {InvalidateSizeOptions | boolean} [options]
*/
invalidateSize(options?: InvalidateSizeOptions | boolean): this;
/**
* Stops the currently running `panTo` or `flyTo` animation, if any.
* @category Methods for modifying map state
*/
stop(): this;
/**
* Tries to locate the user using the Geolocation API, firing a [`locationfound`](#map-locationfound) event
* with location data on success or a [`locationerror`](#map-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 geolocation only works on pages served over HTTPS. See `LocateOptions`
* for more details.
* @category Geolocation methods
* @param {LocateOptions} [options]
*/
locate(options?: LocateOptions): this;
/**
* Stops watching location previously initiated by `map.locate({watch: true})` and
* aborts resetting the map view if map.locate was called with `{setView: true}`.
* @category Geolocation methods
*/
stopLocate(): this;
/** @param {{code: number, message: string}} error */
_handleGeolocationError(error: {
code: number;
message: string;
}): void;
/** @param {GeolocationPosition} pos */
_handleGeolocationResponse(pos: GeolocationPosition): void;
/**
* Adds the given layer to the map
* @category Methods for Layers and Controls
* @param {LayerBase} layer
*/
addLayer(layer: LayerBase): this;
/**
* Removes the given layer from the map.
* @category Methods for Layers and Controls
* @param {LayerBase} layer
*/
removeLayer(layer: LayerBase): this;
/**
* Returns `true` if the given layer is currently added to the map
* @category Methods for Layers and Controls
* @param {LayerBase} layer
*/
hasLayer(layer: LayerBase): boolean;
/**
* Iterates over the layers of the map, optionally specifying context of the iterator function. Open popups and
* tooltips are included too.
* ```
* map.eachLayer(function(layer){
* if (layer instanceof Marker) layer.bindPopup('Hello');
* });
* ```
* @category Methods for Layers and Controls
* @param {(layer: LayerBase) => void} method
* @param {unknown} [context]
*/
eachLayer(method: (layer: LayerBase) => void, context?: unknown): this;
/**
* Opens the specified popup while closing the previously opened
* (to make sure only one is opened at one time for usability).
* @category Methods for Layers and Controls
* @overload
* @param {Popup} popup
* @returns {this}
*/
/**
* Creates a popup with the specified content and options and opens it in the given point on a map. String
* content is rendered as HTML; sanitize untrusted input or pass an `HTMLElement` with safe `textContent`
* instead.
* @overload
* @param {string | HTMLElement} content
* @param {LatLngExpression} latlng
* @param {Partial<PopupOptions>} [options]
* @returns {this}
*/
/**
* @param {Popup | string | HTMLElement} popup
* @param {LatLngExpression} [latlng]
* @param {Partial<PopupOptions>} [options]
*/
openPopup(popup: Popup): this;
/**
* Opens the specified popup while closing the previously opened
* (to make sure only one is opened at one time for usability).
* @category Methods for Layers and Controls
* @overload
* @param {Popup} popup
* @returns {this}
*/
/**
* Creates a popup with the specified content and options and opens it in the given point on a map. String
* content is rendered as HTML; sanitize untrusted input or pass an `HTMLElement` with safe `textContent`
* instead.
* @overload
* @param {string | HTMLElement} content
* @param {LatLngExpression} latlng
* @param {Partial<PopupOptions>} [options]
* @returns {this}
*/
/**
* @param {Popup | string | HTMLElement} popup
* @param {LatLngExpression} [latlng]
* @param {Partial<PopupOptions>} [options]
*/
openPopup(content: string | HTMLElement, latlng: LatLngExpression, options?: Partial<PopupOptions>): this;
/**
* Closes the popup previously opened with [openPopup](#map-openpopup) (or the given one).
* @category Methods for Layers and Controls
* @param {Popup} [popup]
*/
closePopup(popup?: Popup): this;
/**
* Opens the specified tooltip.
* @category Methods for Layers and Controls
* @overload
* @param {Tooltip} tooltip
* @returns {this}
*/
/**
* Creates a tooltip with the specified content and options and open it. String content is rendered
* as HTML; sanitize untrusted input or pass an `HTMLElement` with safe `textContent` instead.
* @overload
* @param {string | HTMLElement} content
* @param {LatLngExpression} latlng
* @param {Partial<TooltipOptions>} [options]
* @returns {this}
*/
/**
* @param {Tooltip | string | HTMLElement} tooltip
* @param {LatLngExpression} [latlng]
* @param {Partial<TooltipOptions>} [options]
*/
openTooltip(tooltip: Tooltip): this;
/**
* Opens the specified tooltip.
* @category Methods for Layers and Controls
* @overload
* @param {Tooltip} tooltip
* @returns {this}
*/
/**
* Creates a tooltip with the specified content and options and open it. String content is rendered
* as HTML; sanitize untrusted input or pass an `HTMLElement` with safe `textContent` instead.
* @overload
* @param {string | HTMLElement} content
* @param {LatLngExpression} latlng
* @param {Partial<TooltipOptions>} [options]
* @returns {this}
*/
/**
* @param {Tooltip | string | HTMLElement} tooltip
* @param {LatLngExpression} [latlng]
* @param {Partial<TooltipOptions>} [options]
*/
openTooltip(content: string | HTMLElement, latlng: LatLngExpression, options?: Partial<TooltipOptions>): this;
/**
* Closes the tooltip given as parameter.
* @category Methods for Layers and Controls
* @param {Tooltip} tooltip
*/
closeTooltip(tooltip: Tooltip): this;
/**
* @template {Popup | Tooltip} T
* @param {new (options?: Partial<PopupOptions & TooltipOptions>) => T} OverlayClass
* @param {T | string | HTMLElement} content
* @param {LatLngExpression} [latlng]
* @param {Partial<PopupOptions & TooltipOptions>} [options]
*/
_initOverlay<T extends Popup | Tooltip>(OverlayClass: new (options?: Partial<PopupOptions & TooltipOptions>) => T, content: T | string | HTMLElement, latlng?: LatLngExpression, options?: Partial<PopupOptions & TooltipOptions>): Popup<PopupOptions, import("../types.js").DivOverlayEventMap> | Tooltip<TooltipOptions, import("../types.js").DivOverlayEventMap>;
/**
* Adds the given control to the map
* @category Methods for Layers and Controls
* @param {Control} control
*/
addControl(control: Control): this;
/**
* Removes the given control from the map
* @category Methods for Layers and Controls
* @param {Control} control
*/
removeControl(control: Control): this;
/**
* 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.
* @category Methods for Layers and Controls
* @param {Path} layer
* @returns {Renderer}
*/
getRenderer(layer: Path): Renderer;
/** @param {Path} layer */
_getPaneRenderer(layer: Path): Renderer<import("../types.js").RendererOptions, import("../types.js").RendererEventMap> | undefined;
/**
* Adds a new `Handler` to the map, given its name and constructor function.
* @category Other Methods
* @param {string} name
* @param {new (map: LeafletMap) => Handler} HandlerClass
*/
addHandler(name: string, HandlerClass: new (map: LeafletMap) => Handler): this;
/**
* @template {Handler} H
* @param {string} name
* @param {new (map: LeafletMap) => H} HandlerClass
*/
_addHandler<H extends Handler>(name: string, HandlerClass: new (map: LeafletMap) => H): H;
/**
* Destroys the map and clears all related event listeners.
* @category Other Methods
*/
remove(): this;
/**
* Creates a new [map pane](#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.
* @category Other Methods
* @param {string} name
* @param {HTMLElement} [container]
* @returns {HTMLElement}
*/
createPane(name: string, container?: HTMLElement): HTMLElement;
/**
* Returns the geographical center of the map view
* @category Methods for Getting Map State
*/
getCenter(): LatLng;
/**
* Returns the current zoom level of the map view
* @category Methods for Getting Map State
*/
getZoom(): number;
/**
* Returns the geographical bounds visible in the current map view
* @category Methods for Getting Map State
*/
getBounds(): LatLngBounds;
/**
* 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.
* @category Methods for Getting Map State
*/
getMinZoom(): number;
/**
* Returns the maximum zoom level of the map (if set in the `maxZoom` option of the map or of any layers).
* @category Methods for Getting Map State
*/
getMaxZoom(): 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.
* @category Methods for Getting Map State
* @param {LatLngBoundsExpression} bounds
* @param {boolean} [inside]
* @param {PointExpression} [padding]
*/
getBoundsZoom(bounds: LatLngBoundsExpression, inside?: boolean, padding?: PointExpression): number;
/**
* Returns the current size of the map container (in pixels).
* @category Methods for Getting Map State
*/
getSize(): Point;
/**
* Returns the bounds of the current map view in projected pixel coordinates (sometimes useful in layer and
* overlay implementations). If `center` and `zoom` is omitted, the map's current zoom level and center is used.
* @category Methods for Getting Map State
* @param {LatLngExpression} [center]
* @param {number} [zoom]
*/
getPixelBounds(center?: LatLngExpression, zoom?: number): Bounds;
/**
* Returns the projected pixel coordinates of the top left point of the
* map layer (useful in custom layer and overlay implementations).
* @category Methods for Getting Map State
*/
getPixelOrigin(): Point;
/**
* Returns the world's bounds in pixel coordinates for zoom level `zoom`.
* If `zoom` is omitted, the map's current zoom level is used.
* @category Methods for Getting Map State
* @param {number} [zoom]
*/
getPixelWorldBounds(zoom?: number): Bounds | null;
/**
* Returns a [map pane](#map-pane), given its name or its HTML element (its identity).
* @category Other Methods
* @param {string | HTMLElement} pane
*/
getPane(pane: string | HTMLElement): HTMLElement;
/**
* Returns a plain object containing the names of all [panes](#map-pane) as keys and the panes as values.
* @category Other Methods
* @returns {MapPanes}
*/
getPanes(): MapPanes;
/**
* Returns the HTML element that contains the map.
* @category Other Methods
* @returns {HTMLElement}
*/
getContainer(): HTMLElement;
/**
* Returns the scale factor to be applied to a map transition from zoom level
* `fromZoom` to `toZoom`. Used internally to help with zoom animations.
* @category Conversion Methods
* @param {number} toZoom
* @param {number} [fromZoom]
*/
getZoomScale(toZoom: number, fromZoom?: number): number;
/**
* 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`](#map-getzoomscale).
* @category Conversion Methods
* @param {number} scale
* @param {number} [fromZoom]
*/
getScaleZoom(scale: number, fromZoom?: number): number;
/**
* 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.
* @category Conversion Methods
* @param {LatLngExpression} latlng
* @param {number} [zoom]
*/
project(latlng: LatLngExpression, zoom?: number): Point;
/**
* Inverse of [`project`](#map-project).
* @category Conversion Methods
* @param {PointExpression} point
* @param {number} [zoom]
*/
unproject(point: PointExpression, zoom?: number): LatLng;
/**
* Given a pixel coordinate relative to the [origin pixel](#map-getpixelorigin), returns
* the corresponding geographical coordinate (for the current zoom level).
* @category Conversion Methods
* @param {PointExpression} point
*/
layerPointToLatLng(point: PointExpression): LatLng;
/**
* Given a geographical coordinate, returns the corresponding pixel
* coordinate relative to the [origin pixel](#map-getpixelorigin).
* @category Conversion Methods
* @param {LatLngExpression} latlng
*/
latLngToLayerPoint(latlng: LatLngExpression): Point;
/**
* 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.
* @category Conversion Methods
* @param {LatLngExpression} latlng
*/
wrapLatLng(latlng: LatLngExpression): LatLng;
/**
* 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.
* @category Conversion Methods
* @param {LatLngBoundsExpression} bounds
*/
wrapLatLngBounds(bounds: LatLngBoundsExpression): LatLngBounds;
/**
* Returns the distance between two geographical coordinates according
* to the map's CRS. By default this measures distance in meters.
* @category Conversion Methods
* @param {LatLngExpression} latlng1
* @param {LatLngExpression} latlng2
*/
distance(latlng1: LatLngExpression, latlng2: LatLngExpression): number;
/**
* Given a pixel coordinate relative to the map container, returns the corresponding
* pixel coordinate relative to the [origin pixel](#map-getpixelorigin).
* @category Conversion Methods
* @param {PointExpression} point
*/
containerPointToLayerPoint(point: PointExpression): Point;
/**
* Given a pixel coordinate relative to the [origin pixel](#map-getpixelorigin),
* returns the corresponding pixel coordinate relative to the map container.
* @category Conversion Methods
* @param {PointExpression} point
*/
layerPointToContainerPoint(point: PointExpression): Point;
/**
* Given a pixel coordinate relative to the map container, returns the corresponding
* geographical coordinate (for the current zoom level).
* @category Conversion Methods
* @param {PointExpression} point
*/
containerPointToLatLng(point: PointExpression): LatLng;
/**
* Given a geographical coordinate, returns the corresponding pixel coordinate relative to the map container.
* @category Conversion Methods
* @param {LatLngExpression} latlng
*/
latLngToContainerPoint(latlng: LatLngExpression): Point;
/**
* Given a PointerEvent object, returns the pixel coordinate relative
* to the map container where the event took place.
* @category Conversion Methods
* @param {PointerEvent | MouseEvent} e
*/
pointerEventToContainerPoint(e: PointerEvent | MouseEvent): Point;
/**
* Given a PointerEvent object, returns the pixel coordinate relative to
* the [origin pixel](#map-getpixelorigin) where the event took place.
* @category Conversion Methods
* @param {PointerEvent | MouseEvent} e
*/
pointerEventToLayerPoint(e: PointerEvent | MouseEvent): Point;
/**
* Given a PointerEvent object, returns geographical coordinate where the event took place.
* @category Conversion Methods
* @param {PointerEvent | MouseEvent} e
*/
pointerEventToLatLng(e: PointerEvent | MouseEvent): LatLng;
/** @param {string | HTMLElement} id */
_initContainer(id: string | HTMLElement): void;
_initLayout(): void;
_initControlPos(): void;
_initPanes(): void;
/**
* @param {LatLng} center
* @param {number} zoom
* @param {boolean} [noMoveStart]
*/
_resetView(center: LatLng, zoom: number, noMoveStart?: boolean): void;
/**
* @param {boolean} zoomChanged
* @param {boolean} [noMoveStart]
*/
_moveStart(zoomChanged: boolean, noMoveStart?: boolean): this;
/**
* @param {LatLng} center
* @param {number} [zoom]
* @param {{flyTo?: boolean, pinch?: boolean}} [data]
* @param {boolean} [suppressEvent]
*/
_move(center: LatLng, zoom?: number, data?: {
flyTo?: boolean;
pinch?: boolean;
}, suppressEvent?: boolean): this;
/** @param {boolean} zoomChanged */
_moveEnd(zoomChanged: boolean): this;
_stop(): this;
/** @param {PointExpression} offset */
_rawPanBy(offset: PointExpression): void;
_wrapWorldCopy(pos?: Point): Point;
/** @param {Layer | Layer[]} [layers] */
_addLayers(layers?: Layer | Layer[]): void;
/** @param {GridLayer} layer */
_addZoomLimit(layer: GridLayer): void;
/** @param {GridLayer} layer */
_removeZoomLimit(layer: GridLayer): void;
_updateZoomLevels(): void;
_getZoomSpan(): number;
_panInsideMaxBounds(): void;
_checkIfLoaded(): void;
/** @param {boolean} [remove] */
_initEvents(remove?: boolean): void;
_onResize(): void;
_onScroll(): void;
_onMoveEnd(): void;
/**
* @param {Event} e
* @param {string} type
*/
_findEventTargets(e: Event, type: string): DOMEventTarget[];
/** @param {Node | null} el */
_isClickDisabled(el: Node | null): true | undefined;
/** @param {Event} e */
_handleDOMEvent(e: Event): void;
static _pointerEvents: string[];
/**
* @param {Event} e
* @param {string} type
* @param {DOMEventTarget[] | false} [canvasTargets]
*/
_fireDOMEvent(e: Event, type: string, canvasTargets?: DOMEventTarget[] | false): void;
/** @param {DOMEventTarget} obj */
_draggableMoved(obj: DOMEventTarget): {} | undefined;
/**
* 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.
* @category Other Methods
* @param {(e: {target: LeafletMap}) => void} callback
* @param {unknown} [context]
*/
whenReady(callback: (e: {
target: LeafletMap;
}) => void, context?: unknown): this;
_getMapPanePos(): Point;
/**
* @param {LatLngExpression} [center]
* @param {number} [zoom]
*/
_getTopLeftPoint(center?: LatLngExpression, zoom?: number): Point;
/**
* @param {LatLngExpression} center
* @param {number} [zoom]
*/
_getNewPixelOrigin(center: LatLngExpression, zoom?: number): Point;
/**
* @param {LatLngExpression} latlng
* @param {number} zoom
* @param {LatLngExpression} center
*/
_latLngToNewLayerPoint(latlng: LatLngExpression, zoom: number, center: LatLngExpression): Point;
_getCenterLayerPoint(): Point;
/** @param {LatLngExpression} latlng */
_getCenterOffset(latlng: LatLngExpression): Point;
/**
* @param {LatLng} center
* @param {number} zoom
* @param {LatLngBoundsExpression | null} [bounds]
*/
_limitCenter(center: LatLng, zoom: number, bounds?: LatLngBoundsExpression | null): LatLng;
_prefersReducedMotion(): boolean;
/**
* @param {Point} offset
* @param {LatLngBoundsExpression | null} [bounds]
*/
_limitOffset(offset: Point, bounds?: LatLngBoundsExpression | null): Point;
/**
* @param {Bounds} pxBounds
* @param {LatLngBoundsExpression} maxBounds
* @param {number} [zoom]
*/
_getBoundsOffset(pxBounds: Bounds, maxBounds: LatLngBoundsExpression, zoom?: number): Point;
/**
* @param {number} left
* @param {number} right
*/
_rebound(left: number, right: number): number;
/** @param {number} zoom */
_limitZoom(zoom: number): number;
_onPanTransitionStep(): void;
_onPanTransitionEnd(): void;
/**
* @param {LatLng} center
* @param {PanOptions} [options]
*/
_tryAnimatedPan(center: LatLng, options?: PanOptions): boolean;
_createAnimProxy(): void;
/** @param {ZoomAnimEvent} e */
_animateProxyZoom(e: ZoomAnimEvent): void;
_animMoveEnd(): void;
/** @param {TransitionEvent} e */
_catchTransitionEnd(e: TransitionEvent): void;
_nothingToAnimate(): boolean;
_zoomInputBlocked(): boolean;
/**
* @param {LatLng} center
* @param {number} zoom
* @param {ZoomPanOptions} [options]
*/
_tryAnimatedZoom(center: LatLng, zoom: number, options?: ZoomPanOptions): boolean;
/**
* @param {LatLng} center
* @param {number} zoom
* @param {boolean} [startAnim]
* @param {boolean} [noUpdate]
*/
_animateZoom(center: LatLng, zoom: number, startAnim?: boolean, noUpdate?: boolean): void;
_onZoomTransitionEnd(): void;
}
export { LeafletMap as Map };