UNPKG

109 kBTypeScriptView Raw
1export as namespace L;
2
3import * as geojson from "geojson";
4
5/** A constant that represents the Leaflet version in use. */
6export const version: string;
7
8export class Class {
9 static extend(props: any): { new(...args: any[]): any } & typeof Class;
10 static include(props: any): any & typeof Class;
11 static mergeOptions(props: any): any & typeof Class;
12
13 static addInitHook(initHookFn: () => void): any & typeof Class;
14 static addInitHook(methodName: string, ...args: any[]): any & typeof Class;
15
16 static callInitHooks(): void;
17}
18
19export class Transformation {
20 constructor(a: number, b: number, c: number, d: number);
21 transform(point: Point, scale?: number): Point;
22 untransform(point: Point, scale?: number): Point;
23}
24
25/** Instantiates a Transformation object with the given coefficients. */
26export function transformation(a: number, b: number, c: number, d: number): Transformation;
27
28/** Expects an coefficients array of the form `[a: Number, b: Number, c: Number, d: Number]`. */
29export function transformation(coefficients: [number, number, number, number]): Transformation;
30
31/**
32 * @see https://github.com/Leaflet/Leaflet/blob/bc918d4bdc2ba189807bc207c77080fb41ecc196/src/geometry/LineUtil.js#L118
33 */
34export namespace LineUtil {
35 function simplify(points: Point[], tolerance: number): Point[];
36 function pointToSegmentDistance(p: Point, p1: Point, p2: Point): number;
37 function closestPointOnSegment(p: Point, p1: Point, p2: Point): Point;
38 function isFlat(latlngs: LatLngExpression[]): boolean;
39 function clipSegment(
40 a: Point,
41 b: Point,
42 bounds: Bounds,
43 useLastCode?: boolean,
44 round?: boolean,
45 ): [Point, Point] | false;
46 function polylineCenter(latlngs: LatLngExpression[], crs: CRS): LatLng;
47}
48
49export namespace PolyUtil {
50 function clipPolygon(points: Point[], bounds: BoundsExpression, round?: boolean): Point[];
51 function polygonCenter(latlngs: LatLngExpression[], crs: CRS): LatLng;
52}
53
54export namespace DomUtil {
55 /**
56 * Get Element by its ID or with the given HTML-Element
57 */
58 function get(element: string | HTMLElement): HTMLElement | null;
59 function getStyle(el: HTMLElement, styleAttrib: string): string | null;
60 /**
61 * Creates an HTML element with `tagName`, sets its class to `className`, and optionally appends it to `container` element.
62 * @param tagName The name of the tag to create (for example: `div` or `canvas`).
63 * @param className The class to set on the created element.
64 * @param container The container to append the created element to.
65 */
66 function create<T extends keyof HTMLElementTagNameMap>(
67 tagName: T,
68 className?: string,
69 container?: HTMLElement,
70 ): HTMLElementTagNameMap[T];
71 function create(tagName: string, className?: string, container?: HTMLElement): HTMLElement;
72 function remove(el: HTMLElement): void;
73 function empty(el: HTMLElement): void;
74 function toFront(el: HTMLElement): void;
75 function toBack(el: HTMLElement): void;
76 function hasClass(el: HTMLElement, name: string): boolean;
77 function addClass(el: HTMLElement, name: string): void;
78 function removeClass(el: HTMLElement, name: string): void;
79 function setClass(el: HTMLElement, name: string): void;
80 function getClass(el: HTMLElement): string;
81 function setOpacity(el: HTMLElement, opacity: number): void;
82 function testProp(props: string[]): string | false;
83 function setTransform(el: HTMLElement, offset: Point, scale?: number): void;
84 function setPosition(el: HTMLElement, position: Point): void;
85 function getPosition(el: HTMLElement): Point;
86 function getScale(el: HTMLElement): { x: number; y: number; boundingClientRect: DOMRect };
87 function getSizedParentNode(el: HTMLElement): HTMLElement;
88 function disableTextSelection(): void;
89 function enableTextSelection(): void;
90 function disableImageDrag(): void;
91 function enableImageDrag(): void;
92 function preventOutline(el: HTMLElement): void;
93 function restoreOutline(): void;
94
95 let TRANSFORM: string;
96 let TRANSITION: string;
97 let TRANSITION_END: string;
98}
99
100export class PosAnimation extends Evented {
101 run(el: HTMLElement, newPos: Point, duration?: number, easeLinearity?: number): void;
102 stop(): void;
103}
104
105export interface CRS {
106 latLngToPoint(latlng: LatLngExpression, zoom: number): Point;
107 pointToLatLng(point: PointExpression, zoom: number): LatLng;
108 project(latlng: LatLng | LatLngLiteral): Point;
109 unproject(point: PointExpression): LatLng;
110 scale(zoom: number): number;
111 zoom(scale: number): number;
112 getProjectedBounds(zoom: number): Bounds;
113 distance(latlng1: LatLngExpression, latlng2: LatLngExpression): number;
114 wrapLatLng(latlng: LatLng | LatLngLiteral): LatLng;
115
116 code?: string | undefined;
117 wrapLng?: [number, number] | undefined;
118 wrapLat?: [number, number] | undefined;
119 infinite: boolean;
120}
121
122export namespace CRS {
123 const EPSG3395: CRS;
124 const EPSG3857: CRS;
125 const EPSG4326: CRS;
126 const EPSG900913: CRS;
127 const Earth: CRS;
128 const Simple: CRS;
129}
130
131export interface Projection {
132 project(latlng: LatLng | LatLngLiteral): Point;
133 unproject(point: PointExpression): LatLng;
134
135 bounds: Bounds;
136}
137
138export namespace Projection {
139 const LonLat: Projection;
140 const Mercator: Projection;
141 const SphericalMercator: Projection;
142}
143
144export class LatLng {
145 constructor(latitude: number, longitude: number, altitude?: number);
146 equals(otherLatLng: LatLngExpression, maxMargin?: number): boolean;
147 toString(): string;
148 distanceTo(otherLatLng: LatLngExpression): number;
149 wrap(): LatLng;
150 toBounds(sizeInMeters: number): LatLngBounds;
151 clone(): LatLng;
152
153 lat: number;
154 lng: number;
155 alt?: number | undefined;
156}
157
158export interface LatLngLiteral {
159 lat: number;
160 lng: number;
161 alt?: number;
162}
163
164export type LatLngTuple = [number, number, number?];
165
166export type LatLngExpression = LatLng | LatLngLiteral | LatLngTuple;
167
168export function latLng(latitude: number, longitude: number, altitude?: number): LatLng;
169
170export function latLng(
171 coords: LatLngTuple | [number, number, number] | LatLngLiteral | {
172 lat: number;
173 lng: number;
174 alt?: number | undefined;
175 },
176): LatLng;
177
178export class LatLngBounds {
179 constructor(southWest: LatLngExpression, northEast: LatLngExpression);
180 constructor(latlngs: LatLngBoundsLiteral);
181 extend(latlngOrBounds: LatLngExpression | LatLngBoundsExpression): this;
182 pad(bufferRatio: number): LatLngBounds; // Returns a new LatLngBounds
183 getCenter(): LatLng;
184 getSouthWest(): LatLng;
185 getNorthEast(): LatLng;
186 getNorthWest(): LatLng;
187 getSouthEast(): LatLng;
188 getWest(): number;
189 getSouth(): number;
190 getEast(): number;
191 getNorth(): number;
192 contains(otherBoundsOrLatLng: LatLngBoundsExpression | LatLngExpression): boolean;
193 intersects(otherBounds: LatLngBoundsExpression): boolean;
194 overlaps(otherBounds: LatLngBoundsExpression): boolean;
195 toBBoxString(): string;
196 equals(otherBounds: LatLngBoundsExpression, maxMargin?: number): boolean;
197 isValid(): boolean;
198}
199
200export type LatLngBoundsLiteral = LatLngTuple[]; // Must be [LatLngTuple, LatLngTuple], cant't change because Map.setMaxBounds
201
202export type LatLngBoundsExpression = LatLngBounds | LatLngBoundsLiteral;
203
204export function latLngBounds(southWest: LatLngExpression, northEast: LatLngExpression): LatLngBounds;
205
206export function latLngBounds(latlngs: LatLngExpression[]): LatLngBounds;
207
208export type PointTuple = [number, number];
209
210export class Point {
211 constructor(x: number, y: number, round?: boolean);
212 clone(): Point;
213 add(otherPoint: PointExpression): Point; // non-destructive, returns a new point
214 subtract(otherPoint: PointExpression): Point;
215 divideBy(num: number): Point;
216 multiplyBy(num: number): Point;
217 scaleBy(scale: PointExpression): Point;
218 unscaleBy(scale: PointExpression): Point;
219 round(): Point;
220 floor(): Point;
221 ceil(): Point;
222 trunc(): Point;
223 distanceTo(otherPoint: PointExpression): number;
224 equals(otherPoint: PointExpression): boolean;
225 contains(otherPoint: PointExpression): boolean;
226 toString(): string;
227 x: number;
228 y: number;
229}
230
231export interface Coords extends Point {
232 z: number;
233}
234
235export type PointExpression = Point | PointTuple;
236
237export function point(x: number, y: number, round?: boolean): Point;
238
239export function point(coords: PointTuple | { x: number; y: number }): Point;
240
241export type BoundsLiteral = [PointTuple, PointTuple];
242
243export class Bounds {
244 constructor(topLeft: PointExpression, bottomRight: PointExpression);
245 constructor(points?: Point[] | BoundsLiteral);
246
247 // tslint:disable:unified-signatures
248 extend(point: PointExpression): this;
249 extend(otherBounds: BoundsExpression): this;
250 // tslint:enable:unified-signatures
251
252 getCenter(round?: boolean): Point;
253 getBottomLeft(): Point;
254 getBottomRight(): Point;
255 getTopLeft(): Point;
256 getTopRight(): Point;
257 getSize(): Point;
258 contains(pointOrBounds: BoundsExpression | PointExpression): boolean;
259 intersects(otherBounds: BoundsExpression): boolean;
260 overlaps(otherBounds: BoundsExpression): boolean;
261 isValid(): boolean;
262 pad(bufferRatio: number): Bounds; // Returns a new Bounds
263 equals(otherBounds: BoundsExpression): boolean;
264
265 min?: Point | undefined;
266 max?: Point | undefined;
267}
268
269export type BoundsExpression = Bounds | BoundsLiteral;
270
271export function bounds(topLeft: PointExpression, bottomRight: PointExpression): Bounds;
272
273export function bounds(points: Point[] | BoundsLiteral): Bounds;
274
275// Event handler types
276
277export type LeafletEventHandlerFn = (event: LeafletEvent) => void;
278
279export type LayersControlEventHandlerFn = (event: LayersControlEvent) => void;
280
281export type LayerEventHandlerFn = (event: LayerEvent) => void;
282
283export type ResizeEventHandlerFn = (event: ResizeEvent) => void;
284
285export type PopupEventHandlerFn = (event: PopupEvent) => void;
286
287export type TooltipEventHandlerFn = (event: TooltipEvent) => void;
288
289export type ErrorEventHandlerFn = (event: ErrorEvent) => void;
290
291export type LocationEventHandlerFn = (event: LocationEvent) => void;
292
293export type LeafletMouseEventHandlerFn = (event: LeafletMouseEvent) => void;
294
295export type LeafletKeyboardEventHandlerFn = (event: LeafletKeyboardEvent) => void;
296
297export type ZoomAnimEventHandlerFn = (event: ZoomAnimEvent) => void;
298
299export type DragEndEventHandlerFn = (event: DragEndEvent) => void;
300
301export type TileEventHandlerFn = (event: TileEvent) => void;
302
303export type TileErrorEventHandlerFn = (event: TileErrorEvent) => void;
304
305export interface LeafletEventHandlerFnMap {
306 baselayerchange?: LayersControlEventHandlerFn | undefined;
307 overlayadd?: LayersControlEventHandlerFn | undefined;
308 overlayremove?: LayersControlEventHandlerFn | undefined;
309
310 layeradd?: LayerEventHandlerFn | undefined;
311 layerremove?: LayerEventHandlerFn | undefined;
312
313 zoomlevelschange?: LeafletEventHandlerFn | undefined;
314 unload?: LeafletEventHandlerFn | undefined;
315 viewreset?: LeafletEventHandlerFn | undefined;
316 load?: LeafletEventHandlerFn | undefined;
317 zoomstart?: LeafletEventHandlerFn | undefined;
318 movestart?: LeafletEventHandlerFn | undefined;
319 zoom?: LeafletEventHandlerFn | undefined;
320 move?: LeafletEventHandlerFn | undefined;
321 zoomend?: LeafletEventHandlerFn | undefined;
322 moveend?: LeafletEventHandlerFn | undefined;
323 autopanstart?: LeafletEventHandlerFn | undefined;
324 dragstart?: LeafletEventHandlerFn | undefined;
325 drag?: LeafletEventHandlerFn | undefined;
326 add?: LeafletEventHandlerFn | undefined;
327 remove?: LeafletEventHandlerFn | undefined;
328 loading?: LeafletEventHandlerFn | undefined;
329 error?: LeafletEventHandlerFn | undefined;
330 update?: LeafletEventHandlerFn | undefined;
331 down?: LeafletEventHandlerFn | undefined;
332 predrag?: LeafletEventHandlerFn | undefined;
333
334 resize?: ResizeEventHandlerFn | undefined;
335
336 popupopen?: PopupEventHandlerFn | undefined;
337 popupclose?: PopupEventHandlerFn | undefined;
338
339 tooltipopen?: TooltipEventHandlerFn | undefined;
340 tooltipclose?: TooltipEventHandlerFn | undefined;
341
342 locationerror?: ErrorEventHandlerFn | undefined;
343
344 locationfound?: LocationEventHandlerFn | undefined;
345
346 click?: LeafletMouseEventHandlerFn | undefined;
347 dblclick?: LeafletMouseEventHandlerFn | undefined;
348 mousedown?: LeafletMouseEventHandlerFn | undefined;
349 mouseup?: LeafletMouseEventHandlerFn | undefined;
350 mouseover?: LeafletMouseEventHandlerFn | undefined;
351 mouseout?: LeafletMouseEventHandlerFn | undefined;
352 mousemove?: LeafletMouseEventHandlerFn | undefined;
353 contextmenu?: LeafletMouseEventHandlerFn | undefined;
354 preclick?: LeafletMouseEventHandlerFn | undefined;
355
356 keypress?: LeafletKeyboardEventHandlerFn | undefined;
357 keydown?: LeafletKeyboardEventHandlerFn | undefined;
358 keyup?: LeafletKeyboardEventHandlerFn | undefined;
359
360 zoomanim?: ZoomAnimEventHandlerFn | undefined;
361
362 dragend?: DragEndEventHandlerFn | undefined;
363
364 tileunload?: TileEventHandlerFn | undefined;
365 tileloadstart?: TileEventHandlerFn | undefined;
366 tileload?: TileEventHandlerFn | undefined;
367 tileabort?: TileEventHandlerFn | undefined;
368
369 tileerror?: TileErrorEventHandlerFn | undefined;
370
371 // [name: string]: any;
372 // You are able add additional properties, but it makes this interface uncheckable.
373}
374
375/**
376 * A set of methods shared between event-powered classes (like Map and Marker).
377 * Generally, events allow you to execute some function when something happens
378 * with an object (e.g. the user clicks on the map, causing the map to fire
379 * 'click' event).
380 */
381// eslint-disable-next-line @definitelytyped/strict-export-declare-modifiers
382declare class Events {
383 /**
384 * Adds a listener function (fn) to a particular event type of the object.
385 * You can optionally specify the context of the listener (object the this
386 * keyword will point to). You can also pass several space-separated types
387 * (e.g. 'click dblclick').
388 */
389 // tslint:disable:unified-signatures
390 on(type: "baselayerchange" | "overlayadd" | "overlayremove", fn: LayersControlEventHandlerFn, context?: any): this;
391 on(type: "layeradd" | "layerremove", fn: LayerEventHandlerFn, context?: any): this;
392 on(
393 type:
394 | "zoomlevelschange"
395 | "unload"
396 | "viewreset"
397 | "load"
398 | "zoomstart"
399 | "movestart"
400 | "zoom"
401 | "move"
402 | "zoomend"
403 | "moveend"
404 | "autopanstart"
405 | "dragstart"
406 | "drag"
407 | "add"
408 | "remove"
409 | "loading"
410 | "error"
411 | "update"
412 | "down"
413 | "predrag",
414 fn: LeafletEventHandlerFn,
415 context?: any,
416 ): this;
417 on(type: "resize", fn: ResizeEventHandlerFn, context?: any): this;
418 on(type: "popupopen" | "popupclose", fn: PopupEventHandlerFn, context?: any): this;
419 on(type: "tooltipopen" | "tooltipclose", fn: TooltipEventHandlerFn, context?: any): this;
420 on(type: "locationerror", fn: ErrorEventHandlerFn, context?: any): this;
421 on(type: "locationfound", fn: LocationEventHandlerFn, context?: any): this;
422 on(
423 type:
424 | "click"
425 | "dblclick"
426 | "mousedown"
427 | "mouseup"
428 | "mouseover"
429 | "mouseout"
430 | "mousemove"
431 | "contextmenu"
432 | "preclick",
433 fn: LeafletMouseEventHandlerFn,
434 context?: any,
435 ): this;
436 on(type: "keypress" | "keydown" | "keyup", fn: LeafletKeyboardEventHandlerFn, context?: any): this;
437 on(type: "zoomanim", fn: ZoomAnimEventHandlerFn, context?: any): this;
438 on(type: "dragend", fn: DragEndEventHandlerFn, context?: any): this;
439 on(type: "tileunload" | "tileloadstart" | "tileload" | "tileabort", fn: TileEventHandlerFn, context?: any): this;
440 on(type: "tileerror", fn: TileErrorEventHandlerFn, context?: any): this;
441 on(type: string, fn: LeafletEventHandlerFn, context?: any): this;
442
443 /**
444 * Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}
445 */
446 on(eventMap: LeafletEventHandlerFnMap): this;
447 // tslint:enable:unified-signatures
448
449 /**
450 * Removes a previously added listener function. If no function is specified,
451 * it will remove all the listeners of that particular event from the object.
452 * Note that if you passed a custom context to on, you must pass the same context
453 * to off in order to remove the listener.
454 */
455 // tslint:disable:unified-signatures
456 off(
457 type: "baselayerchange" | "overlayadd" | "overlayremove",
458 fn?: LayersControlEventHandlerFn,
459 context?: any,
460 ): this;
461 off(type: "layeradd" | "layerremove", fn?: LayerEventHandlerFn, context?: any): this;
462 off(
463 type:
464 | "zoomlevelschange"
465 | "unload"
466 | "viewreset"
467 | "load"
468 | "zoomstart"
469 | "movestart"
470 | "zoom"
471 | "move"
472 | "zoomend"
473 | "moveend"
474 | "autopanstart"
475 | "dragstart"
476 | "drag"
477 | "add"
478 | "remove"
479 | "loading"
480 | "error"
481 | "update"
482 | "down"
483 | "predrag",
484 fn?: LeafletEventHandlerFn,
485 context?: any,
486 ): this;
487 off(type: "resize", fn?: ResizeEventHandlerFn, context?: any): this;
488 off(type: "popupopen" | "popupclose", fn?: PopupEventHandlerFn, context?: any): this;
489 off(type: "tooltipopen" | "tooltipclose", fn?: TooltipEventHandlerFn, context?: any): this;
490 off(type: "locationerror", fn?: ErrorEventHandlerFn, context?: any): this;
491 off(type: "locationfound", fn?: LocationEventHandlerFn, context?: any): this;
492 off(
493 type:
494 | "click"
495 | "dblclick"
496 | "mousedown"
497 | "mouseup"
498 | "mouseover"
499 | "mouseout"
500 | "mousemove"
501 | "contextmenu"
502 | "preclick",
503 fn?: LeafletMouseEventHandlerFn,
504 context?: any,
505 ): this;
506 off(type: "keypress" | "keydown" | "keyup", fn?: LeafletKeyboardEventHandlerFn, context?: any): this;
507 off(type: "zoomanim", fn?: ZoomAnimEventHandlerFn, context?: any): this;
508 off(type: "dragend", fn?: DragEndEventHandlerFn, context?: any): this;
509 off(type: "tileunload" | "tileloadstart" | "tileload" | "tileabort", fn?: TileEventHandlerFn, context?: any): this;
510 off(type: "tileerror", fn?: TileErrorEventHandlerFn, context?: any): this;
511 off(type: string, fn?: LeafletEventHandlerFn, context?: any): this;
512
513 /**
514 * Removes a set of type/listener pairs.
515 */
516 // With an eventMap there are no additional arguments allowed
517 off(eventMap: LeafletEventHandlerFnMap): this;
518
519 /**
520 * Removes all listeners to all events on the object.
521 */
522 off(): this;
523 // tslint:enable:unified-signatures
524
525 /**
526 * Fires an event of the specified type. You can optionally provide a data
527 * object — the first argument of the listener function will contain its properties.
528 * The event might can optionally be propagated to event parents.
529 */
530 fire(type: string, data?: any, propagate?: boolean): this;
531
532 /**
533 * Returns true if a particular event type has any listeners attached to it.
534 */
535 // tslint:disable:unified-signatures
536 listens(
537 type:
538 | "baselayerchange"
539 | "overlayadd"
540 | "overlayremove"
541 | "layeradd"
542 | "layerremove"
543 | "zoomlevelschange"
544 | "unload"
545 | "viewreset"
546 | "load"
547 | "zoomstart"
548 | "movestart"
549 | "zoom"
550 | "move"
551 | "zoomend"
552 | "moveend"
553 | "autopanstart"
554 | "dragstart"
555 | "drag"
556 | "add"
557 | "remove"
558 | "loading"
559 | "error"
560 | "update"
561 | "down"
562 | "predrag"
563 | "resize"
564 | "popupopen"
565 | "tooltipopen"
566 | "tooltipclose"
567 | "locationerror"
568 | "locationfound"
569 | "click"
570 | "dblclick"
571 | "mousedown"
572 | "mouseup"
573 | "mouseover"
574 | "mouseout"
575 | "mousemove"
576 | "contextmenu"
577 | "preclick"
578 | "keypress"
579 | "keydown"
580 | "keyup"
581 | "zoomanim"
582 | "dragend"
583 | "tileunload"
584 | "tileloadstart"
585 | "tileload"
586 | "tileabort"
587 | "tileerror",
588 propagate?: boolean,
589 ): boolean;
590
591 listens(
592 type: "baselayerchange" | "overlayadd" | "overlayremove",
593 fn: LayersControlEventHandlerFn,
594 context?: any,
595 propagate?: boolean,
596 ): boolean;
597 listens(type: "layeradd" | "layerremove", fn: LayerEventHandlerFn, context?: any, propagate?: boolean): boolean;
598 listens(
599 type:
600 | "zoomlevelschange"
601 | "unload"
602 | "viewreset"
603 | "load"
604 | "zoomstart"
605 | "movestart"
606 | "zoom"
607 | "move"
608 | "zoomend"
609 | "moveend"
610 | "autopanstart"
611 | "dragstart"
612 | "drag"
613 | "add"
614 | "remove"
615 | "loading"
616 | "error"
617 | "update"
618 | "down"
619 | "predrag",
620 fn: LeafletEventHandlerFn,
621 context?: any,
622 propagate?: boolean,
623 ): boolean;
624 listens(type: "resize", fn: ResizeEventHandlerFn, context?: any, propagate?: boolean): boolean;
625 listens(type: "popupopen" | "popupclose", fn: PopupEventHandlerFn, context?: any, propagate?: boolean): boolean;
626 listens(
627 type: "tooltipopen" | "tooltipclose",
628 fn: TooltipEventHandlerFn,
629 context?: any,
630 propagate?: boolean,
631 ): boolean;
632 listens(type: "locationerror", fn: ErrorEventHandlerFn, context?: any, propagate?: boolean): boolean;
633 listens(type: "locationfound", fn: LocationEventHandlerFn, context?: any, propagate?: boolean): boolean;
634 listens(
635 type:
636 | "click"
637 | "dblclick"
638 | "mousedown"
639 | "mouseup"
640 | "mouseover"
641 | "mouseout"
642 | "mousemove"
643 | "contextmenu"
644 | "preclick",
645 fn: LeafletMouseEventHandlerFn,
646 context?: any,
647 propagate?: boolean,
648 ): boolean;
649 listens(
650 type: "keypress" | "keydown" | "keyup",
651 fn: LeafletKeyboardEventHandlerFn,
652 context?: any,
653 propagate?: boolean,
654 ): boolean;
655 listens(type: "zoomanim", fn: ZoomAnimEventHandlerFn, context?: any, propagate?: boolean): boolean;
656 listens(type: "dragend", fn: DragEndEventHandlerFn, context?: any, propagate?: boolean): boolean;
657 listens(
658 type: "tileunload" | "tileloadstart" | "tileload" | "tileabort",
659 fn: TileEventHandlerFn,
660 context?: any,
661 propagate?: boolean,
662 ): boolean;
663 listens(type: "tileerror", fn: TileEventHandlerFn, context?: any, propagate?: boolean): boolean;
664 listens(type: string, fn: LeafletEventHandlerFn, context?: any, propagate?: boolean): boolean;
665
666 /**
667 * Behaves as on(...), except the listener will only get fired once and then removed.
668 */
669 // tslint:disable:unified-signatures
670 once(
671 type: "baselayerchange" | "overlayadd" | "overlayremove",
672 fn: LayersControlEventHandlerFn,
673 context?: any,
674 ): this;
675 once(type: "layeradd" | "layerremove", fn: LayerEventHandlerFn, context?: any): this;
676 once(
677 type:
678 | "zoomlevelschange"
679 | "unload"
680 | "viewreset"
681 | "load"
682 | "zoomstart"
683 | "movestart"
684 | "zoom"
685 | "move"
686 | "zoomend"
687 | "moveend"
688 | "autopanstart"
689 | "dragstart"
690 | "drag"
691 | "add"
692 | "remove"
693 | "loading"
694 | "error"
695 | "update"
696 | "down"
697 | "predrag",
698 fn: LeafletEventHandlerFn,
699 context?: any,
700 ): this;
701 once(type: "resize", fn: ResizeEventHandlerFn, context?: any): this;
702 once(type: "popupopen" | "popupclose", fn: PopupEventHandlerFn, context?: any): this;
703 once(type: "tooltipopen" | "tooltipclose", fn: TooltipEventHandlerFn, context?: any): this;
704 once(type: "locationerror", fn: ErrorEventHandlerFn, context?: any): this;
705 once(type: "locationfound", fn: LocationEventHandlerFn, context?: any): this;
706 once(
707 type:
708 | "click"
709 | "dblclick"
710 | "mousedown"
711 | "mouseup"
712 | "mouseover"
713 | "mouseout"
714 | "mousemove"
715 | "contextmenu"
716 | "preclick",
717 fn: LeafletMouseEventHandlerFn,
718 context?: any,
719 ): this;
720 once(type: "keypress" | "keydown" | "keyup", fn: LeafletKeyboardEventHandlerFn, context?: any): this;
721 once(type: "zoomanim", fn: ZoomAnimEventHandlerFn, context?: any): this;
722 once(type: "dragend", fn: DragEndEventHandlerFn, context?: any): this;
723 once(type: "tileunload" | "tileloadstart" | "tileload" | "tileabort", fn: TileEventHandlerFn, context?: any): this;
724 once(type: "tileerror", fn: TileEventHandlerFn, context?: any): this;
725 once(type: string, fn: LeafletEventHandlerFn, context?: any): this;
726
727 /**
728 * Behaves as on(...), except the listener will only get fired once and then removed.
729 */
730 once(eventMap: LeafletEventHandlerFnMap): this;
731 // tslint:enable:unified-signatures
732
733 /**
734 * Adds an event parent - an Evented that will receive propagated events
735 */
736 addEventParent(obj: Evented): this;
737
738 /**
739 * Removes an event parent, so it will stop receiving propagated events
740 */
741 removeEventParent(obj: Evented): this;
742
743 /**
744 * Alias for on(...)
745 *
746 * Adds a listener function (fn) to a particular event type of the object.
747 * You can optionally specify the context of the listener (object the this
748 * keyword will point to). You can also pass several space-separated types
749 * (e.g. 'click dblclick').
750 */
751 // tslint:disable:unified-signatures
752 addEventListener(
753 type: "baselayerchange" | "overlayadd" | "overlayremove",
754 fn: LayersControlEventHandlerFn,
755 context?: any,
756 ): this;
757 addEventListener(type: "layeradd" | "layerremove", fn: LayerEventHandlerFn, context?: any): this;
758 addEventListener(
759 type:
760 | "zoomlevelschange"
761 | "unload"
762 | "viewreset"
763 | "load"
764 | "zoomstart"
765 | "movestart"
766 | "zoom"
767 | "move"
768 | "zoomend"
769 | "moveend"
770 | "autopanstart"
771 | "dragstart"
772 | "drag"
773 | "add"
774 | "remove"
775 | "loading"
776 | "error"
777 | "update"
778 | "down"
779 | "predrag",
780 fn: LeafletEventHandlerFn,
781 context?: any,
782 ): this;
783 addEventListener(type: "resize", fn: ResizeEventHandlerFn, context?: any): this;
784 addEventListener(type: "popupopen" | "popupclose", fn: PopupEventHandlerFn, context?: any): this;
785 addEventListener(type: "tooltipopen" | "tooltipclose", fn: TooltipEventHandlerFn, context?: any): this;
786 addEventListener(type: "locationerror", fn: ErrorEventHandlerFn, context?: any): this;
787 addEventListener(type: "locationfound", fn: LocationEventHandlerFn, context?: any): this;
788 addEventListener(
789 type:
790 | "click"
791 | "dblclick"
792 | "mousedown"
793 | "mouseup"
794 | "mouseover"
795 | "mouseout"
796 | "mousemove"
797 | "contextmenu"
798 | "preclick",
799 fn: LeafletMouseEventHandlerFn,
800 context?: any,
801 ): this;
802 addEventListener(type: "keypress" | "keydown" | "keyup", fn: LeafletKeyboardEventHandlerFn, context?: any): this;
803 addEventListener(type: "zoomanim", fn: ZoomAnimEventHandlerFn, context?: any): this;
804 addEventListener(type: "dragend", fn: DragEndEventHandlerFn, context?: any): this;
805 addEventListener(
806 type: "tileunload" | "tileloadstart" | "tileload" | "tileabort",
807 fn: TileEventHandlerFn,
808 context?: any,
809 ): this;
810 addEventListener(type: "tileerror", fn: TileErrorEventHandlerFn, context?: any): this;
811 addEventListener(type: string, fn: LeafletEventHandlerFn, context?: any): this;
812
813 /**
814 * Alias for on(...)
815 *
816 * Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}
817 */
818 addEventListener(eventMap: LeafletEventHandlerFnMap): this;
819 // tslint:enable:unified-signatures
820
821 /**
822 * Alias for off(...)
823 *
824 * Removes a previously added listener function. If no function is specified,
825 * it will remove all the listeners of that particular event from the object.
826 * Note that if you passed a custom context to on, you must pass the same context
827 * to off in order to remove the listener.
828 */
829 // tslint:disable:unified-signatures
830 removeEventListener(
831 type: "baselayerchange" | "overlayadd" | "overlayremove",
832 fn?: LayersControlEventHandlerFn,
833 context?: any,
834 ): this;
835 removeEventListener(type: "layeradd" | "layerremove", fn?: LayerEventHandlerFn, context?: any): this;
836 removeEventListener(
837 type:
838 | "zoomlevelschange"
839 | "unload"
840 | "viewreset"
841 | "load"
842 | "zoomstart"
843 | "movestart"
844 | "zoom"
845 | "move"
846 | "zoomend"
847 | "moveend"
848 | "autopanstart"
849 | "dragstart"
850 | "drag"
851 | "add"
852 | "remove"
853 | "loading"
854 | "error"
855 | "update"
856 | "down"
857 | "predrag",
858 fn?: LeafletEventHandlerFn,
859 context?: any,
860 ): this;
861 removeEventListener(type: "resize", fn?: ResizeEventHandlerFn, context?: any): this;
862 removeEventListener(type: "popupopen" | "popupclose", fn?: PopupEventHandlerFn, context?: any): this;
863 removeEventListener(type: "tooltipopen" | "tooltipclose", fn?: TooltipEventHandlerFn, context?: any): this;
864 removeEventListener(type: "locationerror", fn?: ErrorEventHandlerFn, context?: any): this;
865 removeEventListener(type: "locationfound", fn?: LocationEventHandlerFn, context?: any): this;
866 removeEventListener(
867 type:
868 | "click"
869 | "dblclick"
870 | "mousedown"
871 | "mouseup"
872 | "mouseover"
873 | "mouseout"
874 | "mousemove"
875 | "contextmenu"
876 | "preclick",
877 fn?: LeafletMouseEventHandlerFn,
878 context?: any,
879 ): this;
880 removeEventListener(
881 type: "keypress" | "keydown" | "keyup",
882 fn?: LeafletKeyboardEventHandlerFn,
883 context?: any,
884 ): this;
885 removeEventListener(type: "zoomanim", fn?: ZoomAnimEventHandlerFn, context?: any): this;
886 removeEventListener(type: "dragend", fn?: DragEndEventHandlerFn, context?: any): this;
887 removeEventListener(
888 type: "tileunload" | "tileloadstart" | "tileload" | "tileabort",
889 fn?: TileEventHandlerFn,
890 context?: any,
891 ): this;
892 removeEventListener(type: "tileerror", fn?: TileErrorEventHandlerFn, context?: any): this;
893 removeEventListener(type: string, fn?: LeafletEventHandlerFn, context?: any): this;
894
895 /**
896 * Alias for off(...)
897 *
898 * Removes a set of type/listener pairs.
899 */
900 removeEventListener(eventMap: LeafletEventHandlerFnMap): this;
901 // tslint:enable:unified-signatures
902
903 /**
904 * Alias for off()
905 *
906 * Removes all listeners to all events on the object.
907 */
908 clearAllEventListeners(): this;
909
910 /**
911 * Alias for once(...)
912 *
913 * Behaves as on(...), except the listener will only get fired once and then removed.
914 */
915 // tslint:disable:unified-signatures
916 addOneTimeEventListener(
917 type: "baselayerchange" | "overlayadd" | "overlayremove",
918 fn: LayersControlEventHandlerFn,
919 context?: any,
920 ): this;
921 addOneTimeEventListener(type: "layeradd" | "layerremove", fn: LayerEventHandlerFn, context?: any): this;
922 addOneTimeEventListener(
923 type:
924 | "zoomlevelschange"
925 | "unload"
926 | "viewreset"
927 | "load"
928 | "zoomstart"
929 | "movestart"
930 | "zoom"
931 | "move"
932 | "zoomend"
933 | "moveend"
934 | "autopanstart"
935 | "dragstart"
936 | "drag"
937 | "add"
938 | "remove"
939 | "loading"
940 | "error"
941 | "update"
942 | "down"
943 | "predrag",
944 fn: LeafletEventHandlerFn,
945 context?: any,
946 ): this;
947 addOneTimeEventListener(type: "resize", fn: ResizeEventHandlerFn, context?: any): this;
948 addOneTimeEventListener(type: "popupopen" | "popupclose", fn: PopupEventHandlerFn, context?: any): this;
949 addOneTimeEventListener(type: "tooltipopen" | "tooltipclose", fn: TooltipEventHandlerFn, context?: any): this;
950 addOneTimeEventListener(type: "locationerror", fn: ErrorEventHandlerFn, context?: any): this;
951 addOneTimeEventListener(type: "locationfound", fn: LocationEventHandlerFn, context?: any): this;
952 addOneTimeEventListener(
953 type:
954 | "click"
955 | "dblclick"
956 | "mousedown"
957 | "mouseup"
958 | "mouseover"
959 | "mouseout"
960 | "mousemove"
961 | "contextmenu"
962 | "preclick",
963 fn: LeafletMouseEventHandlerFn,
964 context?: any,
965 ): this;
966 addOneTimeEventListener(
967 type: "keypress" | "keydown" | "keyup",
968 fn: LeafletKeyboardEventHandlerFn,
969 context?: any,
970 ): this;
971 addOneTimeEventListener(type: "zoomanim", fn: ZoomAnimEventHandlerFn, context?: any): this;
972 addOneTimeEventListener(type: "dragend", fn: DragEndEventHandlerFn, context?: any): this;
973 addOneTimeEventListener(
974 type: "tileunload" | "tileloadstart" | "tileload" | "tileabort",
975 fn: TileEventHandlerFn,
976 context?: any,
977 ): this;
978 addOneTimeEventListener(type: "tileerror", fn: TileErrorEventHandlerFn, context?: any): this;
979 addOneTimeEventListener(type: string, fn: LeafletEventHandlerFn, context?: any): this;
980
981 /**
982 * Alias for once(...)
983 *
984 * Behaves as on(...), except the listener will only get fired once and then removed.
985 */
986 addOneTimeEventListener(eventMap: LeafletEventHandlerFnMap): this;
987 // tslint:enable:unified-signatures
988
989 /**
990 * Alias for fire(...)
991 *
992 * Fires an event of the specified type. You can optionally provide a data
993 * object — the first argument of the listener function will contain its properties.
994 * The event might can optionally be propagated to event parents.
995 */
996 fireEvent(type: string, data?: any, propagate?: boolean): this;
997
998 /**
999 * Alias for listens(...)
1000 *
1001 * Returns true if a particular event type has any listeners attached to it.
1002 */
1003 hasEventListeners(type: string): boolean;
1004}
1005
1006// eslint-disable-next-line @definitelytyped/strict-export-declare-modifiers
1007declare class MixinType {
1008 Events: Events;
1009}
1010
1011export const Mixin: MixinType;
1012
1013/**
1014 * Base class of Leaflet classes supporting events
1015 */
1016export abstract class Evented extends Class {
1017 /**
1018 * Adds a listener function (fn) to a particular event type of the object.
1019 * You can optionally specify the context of the listener (object the this
1020 * keyword will point to). You can also pass several space-separated types
1021 * (e.g. 'click dblclick').
1022 */
1023 // tslint:disable:unified-signatures
1024 on(type: "baselayerchange" | "overlayadd" | "overlayremove", fn: LayersControlEventHandlerFn, context?: any): this;
1025 on(type: "layeradd" | "layerremove", fn: LayerEventHandlerFn, context?: any): this;
1026 on(
1027 type:
1028 | "zoomlevelschange"
1029 | "unload"
1030 | "viewreset"
1031 | "load"
1032 | "zoomstart"
1033 | "movestart"
1034 | "zoom"
1035 | "move"
1036 | "zoomend"
1037 | "moveend"
1038 | "autopanstart"
1039 | "dragstart"
1040 | "drag"
1041 | "add"
1042 | "remove"
1043 | "loading"
1044 | "error"
1045 | "update"
1046 | "down"
1047 | "predrag",
1048 fn: LeafletEventHandlerFn,
1049 context?: any,
1050 ): this;
1051 on(type: "resize", fn: ResizeEventHandlerFn, context?: any): this;
1052 on(type: "popupopen" | "popupclose", fn: PopupEventHandlerFn, context?: any): this;
1053 on(type: "tooltipopen" | "tooltipclose", fn: TooltipEventHandlerFn, context?: any): this;
1054 on(type: "locationerror", fn: ErrorEventHandlerFn, context?: any): this;
1055 on(type: "locationfound", fn: LocationEventHandlerFn, context?: any): this;
1056 on(
1057 type:
1058 | "click"
1059 | "dblclick"
1060 | "mousedown"
1061 | "mouseup"
1062 | "mouseover"
1063 | "mouseout"
1064 | "mousemove"
1065 | "contextmenu"
1066 | "preclick",
1067 fn: LeafletMouseEventHandlerFn,
1068 context?: any,
1069 ): this;
1070 on(type: "keypress" | "keydown" | "keyup", fn: LeafletKeyboardEventHandlerFn, context?: any): this;
1071 on(type: "zoomanim", fn: ZoomAnimEventHandlerFn, context?: any): this;
1072 on(type: "dragend", fn: DragEndEventHandlerFn, context?: any): this;
1073 on(type: "tileunload" | "tileloadstart" | "tileload" | "tileabort", fn: TileEventHandlerFn, context?: any): this;
1074 on(type: "tileerror", fn: TileErrorEventHandlerFn, context?: any): this;
1075 on(type: string, fn: LeafletEventHandlerFn, context?: any): this;
1076
1077 /**
1078 * Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}
1079 */
1080 on(eventMap: LeafletEventHandlerFnMap): this;
1081 // tslint:enable:unified-signatures
1082
1083 /**
1084 * Removes a previously added listener function. If no function is specified,
1085 * it will remove all the listeners of that particular event from the object.
1086 * Note that if you passed a custom context to on, you must pass the same context
1087 * to off in order to remove the listener.
1088 */
1089 // tslint:disable:unified-signatures
1090 off(
1091 type: "baselayerchange" | "overlayadd" | "overlayremove",
1092 fn?: LayersControlEventHandlerFn,
1093 context?: any,
1094 ): this;
1095 off(type: "layeradd" | "layerremove", fn?: LayerEventHandlerFn, context?: any): this;
1096 off(
1097 type:
1098 | "zoomlevelschange"
1099 | "unload"
1100 | "viewreset"
1101 | "load"
1102 | "zoomstart"
1103 | "movestart"
1104 | "zoom"
1105 | "move"
1106 | "zoomend"
1107 | "moveend"
1108 | "autopanstart"
1109 | "dragstart"
1110 | "drag"
1111 | "add"
1112 | "remove"
1113 | "loading"
1114 | "error"
1115 | "update"
1116 | "down"
1117 | "predrag",
1118 fn?: LeafletEventHandlerFn,
1119 context?: any,
1120 ): this;
1121 off(type: "resize", fn?: ResizeEventHandlerFn, context?: any): this;
1122 off(type: "popupopen" | "popupclose", fn?: PopupEventHandlerFn, context?: any): this;
1123 off(type: "tooltipopen" | "tooltipclose", fn?: TooltipEventHandlerFn, context?: any): this;
1124 off(type: "locationerror", fn?: ErrorEventHandlerFn, context?: any): this;
1125 off(type: "locationfound", fn?: LocationEventHandlerFn, context?: any): this;
1126 off(
1127 type:
1128 | "click"
1129 | "dblclick"
1130 | "mousedown"
1131 | "mouseup"
1132 | "mouseover"
1133 | "mouseout"
1134 | "mousemove"
1135 | "contextmenu"
1136 | "preclick",
1137 fn?: LeafletMouseEventHandlerFn,
1138 context?: any,
1139 ): this;
1140 off(type: "keypress" | "keydown" | "keyup", fn?: LeafletKeyboardEventHandlerFn, context?: any): this;
1141 off(type: "zoomanim", fn?: ZoomAnimEventHandlerFn, context?: any): this;
1142 off(type: "dragend", fn?: DragEndEventHandlerFn, context?: any): this;
1143 off(type: "tileunload" | "tileloadstart" | "tileload" | "tileabort", fn?: TileEventHandlerFn, context?: any): this;
1144 off(type: "tileerror", fn?: TileErrorEventHandlerFn, context?: any): this;
1145 off(type: string, fn?: LeafletEventHandlerFn, context?: any): this;
1146
1147 /**
1148 * Removes a set of type/listener pairs.
1149 */
1150 // With an eventMap there are no additional arguments allowed
1151 off(eventMap: LeafletEventHandlerFnMap): this;
1152
1153 /**
1154 * Removes all listeners to all events on the object.
1155 */
1156 off(): this;
1157 // tslint:enable:unified-signatures
1158
1159 /**
1160 * Fires an event of the specified type. You can optionally provide a data
1161 * object — the first argument of the listener function will contain its properties.
1162 * The event might can optionally be propagated to event parents.
1163 */
1164 fire(type: string, data?: any, propagate?: boolean): this;
1165
1166 /**
1167 * Returns true if a particular event type has any listeners attached to it.
1168 */
1169 // tslint:disable:unified-signatures
1170 listens(
1171 type:
1172 | "baselayerchange"
1173 | "overlayadd"
1174 | "overlayremove"
1175 | "layeradd"
1176 | "layerremove"
1177 | "zoomlevelschange"
1178 | "unload"
1179 | "viewreset"
1180 | "load"
1181 | "zoomstart"
1182 | "movestart"
1183 | "zoom"
1184 | "move"
1185 | "zoomend"
1186 | "moveend"
1187 | "autopanstart"
1188 | "dragstart"
1189 | "drag"
1190 | "add"
1191 | "remove"
1192 | "loading"
1193 | "error"
1194 | "update"
1195 | "down"
1196 | "predrag"
1197 | "resize"
1198 | "popupopen"
1199 | "tooltipopen"
1200 | "tooltipclose"
1201 | "locationerror"
1202 | "locationfound"
1203 | "click"
1204 | "dblclick"
1205 | "mousedown"
1206 | "mouseup"
1207 | "mouseover"
1208 | "mouseout"
1209 | "mousemove"
1210 | "contextmenu"
1211 | "preclick"
1212 | "keypress"
1213 | "keydown"
1214 | "keyup"
1215 | "zoomanim"
1216 | "dragend"
1217 | "tileunload"
1218 | "tileloadstart"
1219 | "tileload"
1220 | "tileabort"
1221 | "tileerror",
1222 propagate?: boolean,
1223 ): boolean;
1224
1225 listens(
1226 type: "baselayerchange" | "overlayadd" | "overlayremove",
1227 fn: LayersControlEventHandlerFn,
1228 context?: any,
1229 propagate?: boolean,
1230 ): boolean;
1231 listens(type: "layeradd" | "layerremove", fn: LayerEventHandlerFn, context?: any, propagate?: boolean): boolean;
1232 listens(
1233 type:
1234 | "zoomlevelschange"
1235 | "unload"
1236 | "viewreset"
1237 | "load"
1238 | "zoomstart"
1239 | "movestart"
1240 | "zoom"
1241 | "move"
1242 | "zoomend"
1243 | "moveend"
1244 | "autopanstart"
1245 | "dragstart"
1246 | "drag"
1247 | "add"
1248 | "remove"
1249 | "loading"
1250 | "error"
1251 | "update"
1252 | "down"
1253 | "predrag",
1254 fn: LeafletEventHandlerFn,
1255 context?: any,
1256 propagate?: boolean,
1257 ): boolean;
1258 listens(type: "resize", fn: ResizeEventHandlerFn, context?: any, propagate?: boolean): boolean;
1259 listens(type: "popupopen" | "popupclose", fn: PopupEventHandlerFn, context?: any, propagate?: boolean): boolean;
1260 listens(
1261 type: "tooltipopen" | "tooltipclose",
1262 fn: TooltipEventHandlerFn,
1263 context?: any,
1264 propagate?: boolean,
1265 ): boolean;
1266 listens(type: "locationerror", fn: ErrorEventHandlerFn, context?: any, propagate?: boolean): boolean;
1267 listens(type: "locationfound", fn: LocationEventHandlerFn, context?: any, propagate?: boolean): boolean;
1268 listens(
1269 type:
1270 | "click"
1271 | "dblclick"
1272 | "mousedown"
1273 | "mouseup"
1274 | "mouseover"
1275 | "mouseout"
1276 | "mousemove"
1277 | "contextmenu"
1278 | "preclick",
1279 fn: LeafletMouseEventHandlerFn,
1280 context?: any,
1281 propagate?: boolean,
1282 ): boolean;
1283 listens(
1284 type: "keypress" | "keydown" | "keyup",
1285 fn: LeafletKeyboardEventHandlerFn,
1286 context?: any,
1287 propagate?: boolean,
1288 ): boolean;
1289 listens(type: "zoomanim", fn: ZoomAnimEventHandlerFn, context?: any, propagate?: boolean): boolean;
1290 listens(type: "dragend", fn: DragEndEventHandlerFn, context?: any, propagate?: boolean): boolean;
1291 listens(
1292 type: "tileunload" | "tileloadstart" | "tileload" | "tileabort",
1293 fn: TileEventHandlerFn,
1294 context?: any,
1295 propagate?: boolean,
1296 ): boolean;
1297 listens(type: "tileerror", fn: TileEventHandlerFn, context?: any, propagate?: boolean): boolean;
1298 listens(type: string, fn: LeafletEventHandlerFn, context?: any, propagate?: boolean): boolean;
1299
1300 /**
1301 * Behaves as on(...), except the listener will only get fired once and then removed.
1302 */
1303 // tslint:disable:unified-signatures
1304 once(
1305 type: "baselayerchange" | "overlayadd" | "overlayremove",
1306 fn: LayersControlEventHandlerFn,
1307 context?: any,
1308 ): this;
1309 once(type: "layeradd" | "layerremove", fn: LayerEventHandlerFn, context?: any): this;
1310 once(
1311 type:
1312 | "zoomlevelschange"
1313 | "unload"
1314 | "viewreset"
1315 | "load"
1316 | "zoomstart"
1317 | "movestart"
1318 | "zoom"
1319 | "move"
1320 | "zoomend"
1321 | "moveend"
1322 | "autopanstart"
1323 | "dragstart"
1324 | "drag"
1325 | "add"
1326 | "remove"
1327 | "loading"
1328 | "error"
1329 | "update"
1330 | "down"
1331 | "predrag",
1332 fn: LeafletEventHandlerFn,
1333 context?: any,
1334 ): this;
1335 once(type: "resize", fn: ResizeEventHandlerFn, context?: any): this;
1336 once(type: "popupopen" | "popupclose", fn: PopupEventHandlerFn, context?: any): this;
1337 once(type: "tooltipopen" | "tooltipclose", fn: TooltipEventHandlerFn, context?: any): this;
1338 once(type: "locationerror", fn: ErrorEventHandlerFn, context?: any): this;
1339 once(type: "locationfound", fn: LocationEventHandlerFn, context?: any): this;
1340 once(
1341 type:
1342 | "click"
1343 | "dblclick"
1344 | "mousedown"
1345 | "mouseup"
1346 | "mouseover"
1347 | "mouseout"
1348 | "mousemove"
1349 | "contextmenu"
1350 | "preclick",
1351 fn: LeafletMouseEventHandlerFn,
1352 context?: any,
1353 ): this;
1354 once(type: "keypress" | "keydown" | "keyup", fn: LeafletKeyboardEventHandlerFn, context?: any): this;
1355 once(type: "zoomanim", fn: ZoomAnimEventHandlerFn, context?: any): this;
1356 once(type: "dragend", fn: DragEndEventHandlerFn, context?: any): this;
1357 once(type: "tileunload" | "tileloadstart" | "tileload" | "tileabort", fn: TileEventHandlerFn, context?: any): this;
1358 once(type: "tileerror", fn: TileEventHandlerFn, context?: any): this;
1359 once(type: string, fn: LeafletEventHandlerFn, context?: any): this;
1360
1361 /**
1362 * Behaves as on(...), except the listener will only get fired once and then removed.
1363 */
1364 once(eventMap: LeafletEventHandlerFnMap): this;
1365 // tslint:enable:unified-signatures
1366
1367 /**
1368 * Adds an event parent - an Evented that will receive propagated events
1369 */
1370 addEventParent(obj: Evented): this;
1371
1372 /**
1373 * Removes an event parent, so it will stop receiving propagated events
1374 */
1375 removeEventParent(obj: Evented): this;
1376
1377 /**
1378 * Alias for on(...)
1379 *
1380 * Adds a listener function (fn) to a particular event type of the object.
1381 * You can optionally specify the context of the listener (object the this
1382 * keyword will point to). You can also pass several space-separated types
1383 * (e.g. 'click dblclick').
1384 */
1385 // tslint:disable:unified-signatures
1386 addEventListener(
1387 type: "baselayerchange" | "overlayadd" | "overlayremove",
1388 fn: LayersControlEventHandlerFn,
1389 context?: any,
1390 ): this;
1391 addEventListener(type: "layeradd" | "layerremove", fn: LayerEventHandlerFn, context?: any): this;
1392 addEventListener(
1393 type:
1394 | "zoomlevelschange"
1395 | "unload"
1396 | "viewreset"
1397 | "load"
1398 | "zoomstart"
1399 | "movestart"
1400 | "zoom"
1401 | "move"
1402 | "zoomend"
1403 | "moveend"
1404 | "autopanstart"
1405 | "dragstart"
1406 | "drag"
1407 | "add"
1408 | "remove"
1409 | "loading"
1410 | "error"
1411 | "update"
1412 | "down"
1413 | "predrag",
1414 fn: LeafletEventHandlerFn,
1415 context?: any,
1416 ): this;
1417 addEventListener(type: "resize", fn: ResizeEventHandlerFn, context?: any): this;
1418 addEventListener(type: "popupopen" | "popupclose", fn: PopupEventHandlerFn, context?: any): this;
1419 addEventListener(type: "tooltipopen" | "tooltipclose", fn: TooltipEventHandlerFn, context?: any): this;
1420 addEventListener(type: "locationerror", fn: ErrorEventHandlerFn, context?: any): this;
1421 addEventListener(type: "locationfound", fn: LocationEventHandlerFn, context?: any): this;
1422 addEventListener(
1423 type:
1424 | "click"
1425 | "dblclick"
1426 | "mousedown"
1427 | "mouseup"
1428 | "mouseover"
1429 | "mouseout"
1430 | "mousemove"
1431 | "contextmenu"
1432 | "preclick",
1433 fn: LeafletMouseEventHandlerFn,
1434 context?: any,
1435 ): this;
1436 addEventListener(type: "keypress" | "keydown" | "keyup", fn: LeafletKeyboardEventHandlerFn, context?: any): this;
1437 addEventListener(type: "zoomanim", fn: ZoomAnimEventHandlerFn, context?: any): this;
1438 addEventListener(type: "dragend", fn: DragEndEventHandlerFn, context?: any): this;
1439 addEventListener(
1440 type: "tileunload" | "tileloadstart" | "tileload" | "tileabort",
1441 fn: TileEventHandlerFn,
1442 context?: any,
1443 ): this;
1444 addEventListener(type: "tileerror", fn: TileErrorEventHandlerFn, context?: any): this;
1445 addEventListener(type: string, fn: LeafletEventHandlerFn, context?: any): this;
1446
1447 /**
1448 * Alias for on(...)
1449 *
1450 * Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}
1451 */
1452 addEventListener(eventMap: LeafletEventHandlerFnMap): this;
1453 // tslint:enable:unified-signatures
1454
1455 /**
1456 * Alias for off(...)
1457 *
1458 * Removes a previously added listener function. If no function is specified,
1459 * it will remove all the listeners of that particular event from the object.
1460 * Note that if you passed a custom context to on, you must pass the same context
1461 * to off in order to remove the listener.
1462 */
1463 // tslint:disable:unified-signatures
1464 removeEventListener(
1465 type: "baselayerchange" | "overlayadd" | "overlayremove",
1466 fn?: LayersControlEventHandlerFn,
1467 context?: any,
1468 ): this;
1469 removeEventListener(type: "layeradd" | "layerremove", fn?: LayerEventHandlerFn, context?: any): this;
1470 removeEventListener(
1471 type:
1472 | "zoomlevelschange"
1473 | "unload"
1474 | "viewreset"
1475 | "load"
1476 | "zoomstart"
1477 | "movestart"
1478 | "zoom"
1479 | "move"
1480 | "zoomend"
1481 | "moveend"
1482 | "autopanstart"
1483 | "dragstart"
1484 | "drag"
1485 | "add"
1486 | "remove"
1487 | "loading"
1488 | "error"
1489 | "update"
1490 | "down"
1491 | "predrag",
1492 fn?: LeafletEventHandlerFn,
1493 context?: any,
1494 ): this;
1495 removeEventListener(type: "resize", fn?: ResizeEventHandlerFn, context?: any): this;
1496 removeEventListener(type: "popupopen" | "popupclose", fn?: PopupEventHandlerFn, context?: any): this;
1497 removeEventListener(type: "tooltipopen" | "tooltipclose", fn?: TooltipEventHandlerFn, context?: any): this;
1498 removeEventListener(type: "locationerror", fn?: ErrorEventHandlerFn, context?: any): this;
1499 removeEventListener(type: "locationfound", fn?: LocationEventHandlerFn, context?: any): this;
1500 removeEventListener(
1501 type:
1502 | "click"
1503 | "dblclick"
1504 | "mousedown"
1505 | "mouseup"
1506 | "mouseover"
1507 | "mouseout"
1508 | "mousemove"
1509 | "contextmenu"
1510 | "preclick",
1511 fn?: LeafletMouseEventHandlerFn,
1512 context?: any,
1513 ): this;
1514 removeEventListener(
1515 type: "keypress" | "keydown" | "keyup",
1516 fn?: LeafletKeyboardEventHandlerFn,
1517 context?: any,
1518 ): this;
1519 removeEventListener(type: "zoomanim", fn?: ZoomAnimEventHandlerFn, context?: any): this;
1520 removeEventListener(type: "dragend", fn?: DragEndEventHandlerFn, context?: any): this;
1521 removeEventListener(
1522 type: "tileunload" | "tileloadstart" | "tileload" | "tileabort",
1523 fn?: TileEventHandlerFn,
1524 context?: any,
1525 ): this;
1526 removeEventListener(type: "tileerror", fn?: TileErrorEventHandlerFn, context?: any): this;
1527 removeEventListener(type: string, fn?: LeafletEventHandlerFn, context?: any): this;
1528
1529 /**
1530 * Alias for off(...)
1531 *
1532 * Removes a set of type/listener pairs.
1533 */
1534 removeEventListener(eventMap: LeafletEventHandlerFnMap): this;
1535 // tslint:enable:unified-signatures
1536
1537 /**
1538 * Alias for off()
1539 *
1540 * Removes all listeners to all events on the object.
1541 */
1542 clearAllEventListeners(): this;
1543
1544 /**
1545 * Alias for once(...)
1546 *
1547 * Behaves as on(...), except the listener will only get fired once and then removed.
1548 */
1549 // tslint:disable:unified-signatures
1550 addOneTimeEventListener(
1551 type: "baselayerchange" | "overlayadd" | "overlayremove",
1552 fn: LayersControlEventHandlerFn,
1553 context?: any,
1554 ): this;
1555 addOneTimeEventListener(type: "layeradd" | "layerremove", fn: LayerEventHandlerFn, context?: any): this;
1556 addOneTimeEventListener(
1557 type:
1558 | "zoomlevelschange"
1559 | "unload"
1560 | "viewreset"
1561 | "load"
1562 | "zoomstart"
1563 | "movestart"
1564 | "zoom"
1565 | "move"
1566 | "zoomend"
1567 | "moveend"
1568 | "autopanstart"
1569 | "dragstart"
1570 | "drag"
1571 | "add"
1572 | "remove"
1573 | "loading"
1574 | "error"
1575 | "update"
1576 | "down"
1577 | "predrag",
1578 fn: LeafletEventHandlerFn,
1579 context?: any,
1580 ): this;
1581 addOneTimeEventListener(type: "resize", fn: ResizeEventHandlerFn, context?: any): this;
1582 addOneTimeEventListener(type: "popupopen" | "popupclose", fn: PopupEventHandlerFn, context?: any): this;
1583 addOneTimeEventListener(type: "tooltipopen" | "tooltipclose", fn: TooltipEventHandlerFn, context?: any): this;
1584 addOneTimeEventListener(type: "locationerror", fn: ErrorEventHandlerFn, context?: any): this;
1585 addOneTimeEventListener(type: "locationfound", fn: LocationEventHandlerFn, context?: any): this;
1586 addOneTimeEventListener(
1587 type:
1588 | "click"
1589 | "dblclick"
1590 | "mousedown"
1591 | "mouseup"
1592 | "mouseover"
1593 | "mouseout"
1594 | "mousemove"
1595 | "contextmenu"
1596 | "preclick",
1597 fn: LeafletMouseEventHandlerFn,
1598 context?: any,
1599 ): this;
1600 addOneTimeEventListener(
1601 type: "keypress" | "keydown" | "keyup",
1602 fn: LeafletKeyboardEventHandlerFn,
1603 context?: any,
1604 ): this;
1605 addOneTimeEventListener(type: "zoomanim", fn: ZoomAnimEventHandlerFn, context?: any): this;
1606 addOneTimeEventListener(type: "dragend", fn: DragEndEventHandlerFn, context?: any): this;
1607 addOneTimeEventListener(
1608 type: "tileunload" | "tileloadstart" | "tileload" | "tileabort",
1609 fn: TileEventHandlerFn,
1610 context?: any,
1611 ): this;
1612 addOneTimeEventListener(type: "tileerror", fn: TileErrorEventHandlerFn, context?: any): this;
1613 addOneTimeEventListener(type: string, fn: LeafletEventHandlerFn, context?: any): this;
1614
1615 /**
1616 * Alias for once(...)
1617 *
1618 * Behaves as on(...), except the listener will only get fired once and then removed.
1619 */
1620 addOneTimeEventListener(eventMap: LeafletEventHandlerFnMap): this;
1621 // tslint:enable:unified-signatures
1622
1623 /**
1624 * Alias for fire(...)
1625 *
1626 * Fires an event of the specified type. You can optionally provide a data
1627 * object — the first argument of the listener function will contain its properties.
1628 * The event might can optionally be propagated to event parents.
1629 */
1630 fireEvent(type: string, data?: any, propagate?: boolean): this;
1631
1632 /**
1633 * Alias for listens(...)
1634 *
1635 * Returns true if a particular event type has any listeners attached to it.
1636 */
1637 hasEventListeners(type: string): boolean;
1638}
1639
1640export interface DraggableOptions {
1641 /**
1642 * The max number of pixels a user can shift the mouse pointer during a click
1643 * for it to be considered a valid click (as opposed to a mouse drag).
1644 */
1645 clickTolerance: number;
1646}
1647
1648/**
1649 * A class for making DOM elements draggable (including touch support).
1650 * Used internally for map and marker dragging. Only works for elements
1651 * that were positioned with [`L.DomUtil.setPosition`](#domutil-setposition).
1652 */
1653export class Draggable extends Evented {
1654 constructor(
1655 element: HTMLElement,
1656 dragStartTarget?: HTMLElement,
1657 preventOutline?: boolean,
1658 options?: DraggableOptions,
1659 );
1660
1661 enable(): void;
1662
1663 disable(): void;
1664
1665 finishDrag(): void;
1666}
1667
1668export interface LayerOptions {
1669 pane?: string | undefined;
1670 attribution?: string | undefined;
1671}
1672
1673export interface InteractiveLayerOptions extends LayerOptions {
1674 interactive?: boolean | undefined;
1675 bubblingMouseEvents?: boolean | undefined;
1676}
1677
1678export class Layer extends Evented {
1679 constructor(options?: LayerOptions);
1680 addTo(map: Map | LayerGroup): this;
1681 remove(): this;
1682 removeFrom(map: Map): this;
1683 getPane(name?: string): HTMLElement | undefined;
1684
1685 addInteractiveTarget(targetEl: HTMLElement): this;
1686 removeInteractiveTarget(targetEl: HTMLElement): this;
1687
1688 // Popup methods
1689 bindPopup(content: ((layer: Layer) => Content) | Content | Popup, options?: PopupOptions): this;
1690 unbindPopup(): this;
1691 openPopup(latlng?: LatLngExpression): this;
1692 closePopup(): this;
1693 togglePopup(): this;
1694 isPopupOpen(): boolean;
1695 setPopupContent(content: Content | Popup): this;
1696 getPopup(): Popup | undefined;
1697
1698 // Tooltip methods
1699 bindTooltip(content: ((layer: Layer) => Content) | Tooltip | Content, options?: TooltipOptions): this;
1700 unbindTooltip(): this;
1701 openTooltip(latlng?: LatLngExpression): this;
1702 closeTooltip(): this;
1703 toggleTooltip(): this;
1704 isTooltipOpen(): boolean;
1705 setTooltipContent(content: Content | Tooltip): this;
1706 getTooltip(): Tooltip | undefined;
1707
1708 // Extension methods
1709 onAdd(map: Map): this;
1710 onRemove(map: Map): this;
1711 getEvents?(): { [name: string]: LeafletEventHandlerFn };
1712 getAttribution?(): string | null;
1713 beforeAdd?(map: Map): this;
1714
1715 protected _map: Map;
1716
1717 options: LayerOptions;
1718}
1719
1720export interface GridLayerOptions extends LayerOptions {
1721 tileSize?: number | Point | undefined;
1722 opacity?: number | undefined;
1723 updateWhenIdle?: boolean | undefined;
1724 updateWhenZooming?: boolean | undefined;
1725 updateInterval?: number | undefined;
1726 zIndex?: number | undefined;
1727 bounds?: LatLngBoundsExpression | undefined;
1728 minZoom?: number | undefined;
1729 maxZoom?: number | undefined;
1730 /**
1731 * Maximum zoom number the tile source has available. If it is specified, the tiles on all zoom levels higher than
1732 * `maxNativeZoom` will be loaded from `maxNativeZoom` level and auto-scaled.
1733 */
1734 maxNativeZoom?: number | undefined;
1735 /**
1736 * Minimum zoom number the tile source has available. If it is specified, the tiles on all zoom levels lower than
1737 * `minNativeZoom` will be loaded from `minNativeZoom` level and auto-scaled.
1738 */
1739 minNativeZoom?: number | undefined;
1740 noWrap?: boolean | undefined;
1741 pane?: string | undefined;
1742 className?: string | undefined;
1743 keepBuffer?: number | undefined;
1744}
1745
1746export type DoneCallback = (error?: Error, tile?: HTMLElement) => void;
1747
1748export interface InternalTiles {
1749 [key: string]: {
1750 active?: boolean | undefined;
1751 coords: Coords;
1752 current: boolean;
1753 el: HTMLElement;
1754 loaded?: Date | undefined;
1755 retain?: boolean | undefined;
1756 };
1757}
1758
1759export class GridLayer extends Layer {
1760 constructor(options?: GridLayerOptions);
1761 bringToFront(): this;
1762 bringToBack(): this;
1763 getContainer(): HTMLElement | null;
1764 setOpacity(opacity: number): this;
1765 setZIndex(zIndex: number): this;
1766 isLoading(): boolean;
1767 redraw(): this;
1768 getTileSize(): Point;
1769
1770 protected createTile(coords: Coords, done: DoneCallback): HTMLElement;
1771 protected _tileCoordsToKey(coords: Coords): string;
1772 protected _wrapCoords(parameter: Coords): Coords;
1773
1774 protected _tiles: InternalTiles;
1775 protected _tileZoom?: number | undefined;
1776}
1777
1778export function gridLayer(options?: GridLayerOptions): GridLayer;
1779
1780export interface TileLayerOptions extends GridLayerOptions {
1781 id?: string | undefined;
1782 accessToken?: string | undefined;
1783 minZoom?: number | undefined;
1784 maxZoom?: number | undefined;
1785 maxNativeZoom?: number | undefined;
1786 minNativeZoom?: number | undefined;
1787 subdomains?: string | string[] | undefined;
1788 errorTileUrl?: string | undefined;
1789 zoomOffset?: number | undefined;
1790 tms?: boolean | undefined;
1791 zoomReverse?: boolean | undefined;
1792 detectRetina?: boolean | undefined;
1793 crossOrigin?: CrossOrigin | boolean | undefined;
1794 referrerPolicy?: ReferrerPolicy | boolean | undefined;
1795 // [name: string]: any;
1796 // You are able add additional properties, but it makes this interface uncheckable.
1797 // See: https://github.com/DefinitelyTyped/DefinitelyTyped/issues/15313
1798 // Example:
1799 // tileLayer = L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png?{foo}&{bar}&{abc}', {foo: 'bar', bar: (data: any) => 'foo', abc: () => ''});
1800}
1801
1802export class TileLayer extends GridLayer {
1803 constructor(urlTemplate: string, options?: TileLayerOptions);
1804 setUrl(url: string, noRedraw?: boolean): this;
1805 getTileUrl(coords: L.Coords): string;
1806
1807 protected _tileOnLoad(done: L.DoneCallback, tile: HTMLElement): void;
1808 protected _tileOnError(done: L.DoneCallback, tile: HTMLElement, e: Error): void;
1809 protected _abortLoading(): void;
1810 protected _getZoomForUrl(): number;
1811
1812 options: TileLayerOptions;
1813}
1814
1815export function tileLayer(urlTemplate: string, options?: TileLayerOptions): TileLayer;
1816
1817export namespace TileLayer {
1818 class WMS extends TileLayer {
1819 constructor(baseUrl: string, options: WMSOptions);
1820 setParams(params: WMSParams, noRedraw?: boolean): this;
1821
1822 wmsParams: WMSParams;
1823 options: WMSOptions;
1824 }
1825}
1826
1827export interface WMSOptions extends TileLayerOptions {
1828 layers?: string | undefined;
1829 styles?: string | undefined;
1830 format?: string | undefined;
1831 transparent?: boolean | undefined;
1832 version?: string | undefined;
1833 crs?: CRS | undefined;
1834 uppercase?: boolean | undefined;
1835}
1836
1837export interface WMSParams {
1838 format?: string | undefined;
1839 layers: string;
1840 request?: string | undefined;
1841 service?: string | undefined;
1842 styles?: string | undefined;
1843 version?: string | undefined;
1844 transparent?: boolean | undefined;
1845 width?: number | undefined;
1846 height?: number | undefined;
1847}
1848
1849export namespace tileLayer {
1850 function wms(baseUrl: string, options?: WMSOptions): TileLayer.WMS;
1851}
1852
1853export type CrossOrigin = "anonymous" | "use-credentials" | "";
1854export type ReferrerPolicy =
1855 | "no-referrer"
1856 | "no-referrer-when-downgrade"
1857 | "origin"
1858 | "origin-when-cross-origin"
1859 | "same-origin"
1860 | "strict-origin"
1861 | "strict-origin-when-cross-origin"
1862 | "unsafe-url";
1863
1864export interface ImageOverlayOptions extends InteractiveLayerOptions {
1865 opacity?: number | undefined;
1866 alt?: string | undefined;
1867 interactive?: boolean | undefined;
1868 crossOrigin?: CrossOrigin | boolean | undefined;
1869 errorOverlayUrl?: string | undefined;
1870 zIndex?: number | undefined;
1871 className?: string | undefined;
1872}
1873
1874export interface ImageOverlayStyleOptions {
1875 opacity?: number;
1876 [name: string]: any;
1877}
1878
1879export class ImageOverlay extends Layer {
1880 constructor(imageUrl: string, bounds: LatLngBoundsExpression, options?: ImageOverlayOptions);
1881 bringToFront(): this;
1882 bringToBack(): this;
1883 setUrl(url: string): this;
1884
1885 /** Update the bounds that this ImageOverlay covers */
1886 setBounds(bounds: LatLngBounds): this;
1887
1888 /** Changes the zIndex of the image overlay */
1889 setZIndex(value: number): this;
1890
1891 /** Changes the opacity of the image element */
1892 setOpacity(opacity: number): this;
1893
1894 /** Changes the style of the image element. As of 1.8, only the opacity is changed */
1895 setStyle(styleOpts: ImageOverlayStyleOptions): this;
1896
1897 /** Get the bounds that this ImageOverlay covers */
1898 getBounds(): LatLngBounds;
1899
1900 /** Get the center of the bounds this ImageOverlay covers */
1901 getCenter(): Point;
1902
1903 /** Get the img element that represents the ImageOverlay on the map */
1904 getElement(): HTMLImageElement | undefined;
1905
1906 options: ImageOverlayOptions;
1907}
1908
1909export function imageOverlay(
1910 imageUrl: string,
1911 bounds: LatLngBoundsExpression,
1912 options?: ImageOverlayOptions,
1913): ImageOverlay;
1914
1915export type SVGOverlayStyleOptions = ImageOverlayStyleOptions;
1916
1917export class SVGOverlay extends Layer {
1918 /** SVGOverlay doesn't extend ImageOverlay because SVGOverlay.getElement returns SVGElement */
1919
1920 constructor(svgImage: string | SVGElement, bounds: LatLngBoundsExpression, options?: ImageOverlayOptions);
1921 bringToFront(): this;
1922 bringToBack(): this;
1923 setUrl(url: string): this;
1924
1925 /** Update the bounds that this SVGOverlay covers */
1926 setBounds(bounds: LatLngBounds): this;
1927
1928 /** Changes the zIndex of the image overlay */
1929 setZIndex(value: number): this;
1930
1931 /** Changes the opacity of the image element */
1932 setOpacity(opacity: number): this;
1933
1934 /** Changes the style of the image element. As of 1.8, only the opacity is changed */
1935 setStyle(styleOpts: SVGOverlayStyleOptions): this;
1936
1937 /** Get the bounds that this SVGOverlay covers */
1938 getBounds(): LatLngBounds;
1939
1940 /** Get the center of the bounds this ImageOverlay covers */
1941 getCenter(): Point;
1942
1943 /** Get the img element that represents the SVGOverlay on the map */
1944 getElement(): SVGElement | undefined;
1945
1946 options: ImageOverlayOptions;
1947}
1948
1949export function svgOverlay(
1950 svgImage: string | SVGElement,
1951 bounds: LatLngBoundsExpression,
1952 options?: ImageOverlayOptions,
1953): SVGOverlay;
1954
1955export interface VideoOverlayOptions extends ImageOverlayOptions {
1956 /** Whether the video starts playing automatically when loaded. */
1957 autoplay?: boolean | undefined;
1958 /** Whether the video will loop back to the beginning when played. */
1959 loop?: boolean | undefined;
1960 /**
1961 * Whether the video will save aspect ratio after the projection. Relevant for supported browsers. See
1962 * [browser compatibility](https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit)
1963 */
1964 keepAspectRatio?: boolean | undefined;
1965 /** Whether the video starts on mute when loaded. */
1966 muted?: boolean | undefined;
1967 playsInline?: boolean | undefined;
1968}
1969
1970export class VideoOverlay extends Layer {
1971 /** VideoOverlay doesn't extend ImageOverlay because VideoOverlay.getElement returns HTMLImageElement */
1972 constructor(
1973 video: string | string[] | HTMLVideoElement,
1974 bounds: LatLngBoundsExpression,
1975 options?: VideoOverlayOptions,
1976 );
1977 bringToFront(): this;
1978 bringToBack(): this;
1979 setUrl(url: string): this;
1980
1981 /** Update the bounds that this VideoOverlay covers */
1982 setBounds(bounds: LatLngBounds): this;
1983
1984 /** Changes the zIndex of the image overlay */
1985 setZIndex(value: number): this;
1986
1987 /** Changes the opacity of the image element */
1988 setOpacity(opacity: number): this;
1989
1990 /** Changes the style of the image element. As of 1.8, only the opacity is changed */
1991 setStyle(styleOpts: SVGOverlayStyleOptions): this;
1992
1993 /** Get the bounds that this VideoOverlay covers */
1994 getBounds(): LatLngBounds;
1995
1996 /** Get the center of the bounds this ImageOverlay covers */
1997 getCenter(): Point;
1998
1999 /** Get the video element that represents the VideoOverlay on the map */
2000 getElement(): HTMLVideoElement | undefined;
2001
2002 options: VideoOverlayOptions;
2003}
2004
2005export function videoOverlay(
2006 video: string | string[] | HTMLVideoElement,
2007 bounds: LatLngBoundsExpression,
2008 options?: VideoOverlayOptions,
2009): VideoOverlay;
2010
2011export type LineCapShape = "butt" | "round" | "square" | "inherit";
2012
2013export type LineJoinShape = "miter" | "round" | "bevel" | "inherit";
2014
2015export type FillRule = "nonzero" | "evenodd" | "inherit";
2016
2017export interface PathOptions extends InteractiveLayerOptions {
2018 stroke?: boolean | undefined;
2019 color?: string | undefined;
2020 weight?: number | undefined;
2021 opacity?: number | undefined;
2022 lineCap?: LineCapShape | undefined;
2023 lineJoin?: LineJoinShape | undefined;
2024 dashArray?: string | number[] | undefined;
2025 dashOffset?: string | undefined;
2026 fill?: boolean | undefined;
2027 fillColor?: string | undefined;
2028 fillOpacity?: number | undefined;
2029 fillRule?: FillRule | undefined;
2030 renderer?: Renderer | undefined;
2031 className?: string | undefined;
2032}
2033
2034export abstract class Path extends Layer {
2035 redraw(): this;
2036 setStyle(style: PathOptions): this;
2037 bringToFront(): this;
2038 bringToBack(): this;
2039 getElement(): Element | undefined;
2040
2041 options: PathOptions;
2042}
2043
2044export interface PolylineOptions extends PathOptions {
2045 smoothFactor?: number | undefined;
2046 noClip?: boolean | undefined;
2047}
2048
2049export class Polyline<T extends geojson.GeometryObject = geojson.LineString | geojson.MultiLineString, P = any>
2050 extends Path
2051{
2052 constructor(latlngs: LatLngExpression[] | LatLngExpression[][], options?: PolylineOptions);
2053 toGeoJSON(precision?: number | false): geojson.Feature<T, P>;
2054 getLatLngs(): LatLng[] | LatLng[][] | LatLng[][][];
2055 setLatLngs(latlngs: LatLngExpression[] | LatLngExpression[][] | LatLngExpression[][][]): this;
2056 isEmpty(): boolean;
2057 getCenter(): LatLng;
2058 getBounds(): LatLngBounds;
2059 addLatLng(latlng: LatLngExpression | LatLngExpression[], latlngs?: LatLng[]): this;
2060 closestLayerPoint(p: Point): Point;
2061
2062 feature?: geojson.Feature<T, P> | undefined;
2063 options: PolylineOptions;
2064}
2065
2066export function polyline<T extends geojson.GeometryObject = geojson.LineString | geojson.MultiLineString, P = any>(
2067 latlngs: LatLngExpression[] | LatLngExpression[][],
2068 options?: PolylineOptions,
2069): Polyline<T, P>;
2070
2071export class Polygon<P = any> extends Polyline<geojson.Polygon | geojson.MultiPolygon, P> {
2072 constructor(latlngs: LatLngExpression[] | LatLngExpression[][] | LatLngExpression[][][], options?: PolylineOptions);
2073}
2074
2075export function polygon<P = any>(
2076 latlngs: LatLngExpression[] | LatLngExpression[][] | LatLngExpression[][][],
2077 options?: PolylineOptions,
2078): Polygon<P>;
2079
2080export class Rectangle<P = any> extends Polygon<P> {
2081 constructor(latLngBounds: LatLngBoundsExpression, options?: PolylineOptions);
2082 setBounds(latLngBounds: LatLngBoundsExpression): this;
2083}
2084
2085export function rectangle<P = any>(latLngBounds: LatLngBoundsExpression, options?: PolylineOptions): Rectangle<P>;
2086
2087export interface CircleMarkerOptions extends PathOptions {
2088 radius: number;
2089}
2090
2091export class CircleMarker<P = any> extends Path {
2092 constructor(latlng: LatLngExpression, options: CircleMarkerOptions);
2093 toGeoJSON(precision?: number | false): geojson.Feature<geojson.Point, P>;
2094 setLatLng(latLng: LatLngExpression): this;
2095 getLatLng(): LatLng;
2096 setRadius(radius: number): this;
2097 getRadius(): number;
2098 setStyle(options: Partial<CircleMarkerOptions>): this;
2099
2100 options: CircleMarkerOptions;
2101 feature?: geojson.Feature<geojson.Point, P> | undefined;
2102}
2103
2104export function circleMarker<P = any>(latlng: LatLngExpression, options?: CircleMarkerOptions): CircleMarker<P>;
2105
2106export type CircleOptions = CircleMarkerOptions;
2107
2108export class Circle<P = any> extends CircleMarker<P> {
2109 constructor(latlng: LatLngExpression, options: CircleOptions);
2110 constructor(latlng: LatLngExpression, radius: number, options?: CircleOptions); // deprecated!
2111 toGeoJSON(precision?: number | false): any;
2112 getBounds(): LatLngBounds;
2113 setRadius(radius: number): this;
2114 getRadius(): number;
2115 setStyle(style: PathOptions): this;
2116}
2117
2118export function circle<P = any>(latlng: LatLngExpression, options: CircleMarkerOptions): Circle<P>;
2119/**
2120 * @deprecated Passing the radius outside the options is deperecated. Use {@link circle:1} instead.
2121 */
2122export function circle<P = any>(latlng: LatLngExpression, radius: number, options?: CircleMarkerOptions): Circle<P>;
2123
2124export interface RendererOptions extends LayerOptions {
2125 padding?: number | undefined;
2126 tolerance?: number | undefined;
2127}
2128
2129export class Renderer extends Layer {
2130 constructor(options?: RendererOptions);
2131
2132 options: RendererOptions;
2133}
2134
2135export class SVG extends Renderer {}
2136
2137export namespace SVG {
2138 function create<K extends keyof SVGElementTagNameMap>(name: K): SVGElementTagNameMap[K];
2139 function create(name: string): SVGElement;
2140
2141 function pointsToPath(rings: PointExpression[], closed: boolean): string;
2142}
2143
2144export function svg(options?: RendererOptions): SVG;
2145
2146export class Canvas extends Renderer {}
2147
2148export function canvas(options?: RendererOptions): Canvas;
2149
2150/**
2151 * Used to group several layers and handle them as one.
2152 * If you add it to the map, any layers added or removed from the group will be
2153 * added/removed on the map as well. Extends Layer.
2154 */
2155export class LayerGroup<P = any> extends Layer {
2156 constructor(layers?: Layer[], options?: LayerOptions);
2157
2158 toMultiPoint(precision?: number): geojson.Feature<geojson.MultiPoint, P>;
2159
2160 /**
2161 * Returns a GeoJSON representation of the layer group (as a GeoJSON GeometryCollection, GeoJSONFeatureCollection or Multipoint).
2162 */
2163 toGeoJSON(
2164 precision?: number | false,
2165 ):
2166 | geojson.FeatureCollection<geojson.GeometryObject, P>
2167 | geojson.Feature<geojson.MultiPoint, P>
2168 | geojson.GeometryCollection;
2169
2170 /**
2171 * Adds the given layer to the group.
2172 */
2173 addLayer(layer: Layer): this;
2174
2175 /**
2176 * Removes the layer with the given internal ID or the given layer from the group.
2177 */
2178 removeLayer(layer: number | Layer): this;
2179
2180 /**
2181 * Returns true if the given layer is currently added to the group.
2182 */
2183 hasLayer(layer: Layer): boolean;
2184
2185 /**
2186 * Removes all the layers from the group.
2187 */
2188 clearLayers(): this;
2189
2190 /**
2191 * Calls methodName on every layer contained in this group, passing any additional parameters.
2192 * Has no effect if the layers contained do not implement methodName.
2193 */
2194 invoke(methodName: string, ...params: any[]): this;
2195
2196 /**
2197 * Iterates over the layers of the group,
2198 * optionally specifying context of the iterator function.
2199 */
2200 eachLayer(fn: (layer: Layer) => void, context?: any): this;
2201
2202 /**
2203 * Returns the layer with the given internal ID.
2204 */
2205 getLayer(id: number): Layer | undefined;
2206
2207 /**
2208 * Returns an array of all the layers added to the group.
2209 */
2210 getLayers(): Layer[];
2211
2212 /**
2213 * Calls setZIndex on every layer contained in this group, passing the z-index.
2214 */
2215 setZIndex(zIndex: number): this;
2216
2217 /**
2218 * Returns the internal ID for a layer
2219 */
2220 getLayerId(layer: Layer): number;
2221
2222 feature?:
2223 | geojson.FeatureCollection<geojson.GeometryObject, P>
2224 | geojson.Feature<geojson.MultiPoint, P>
2225 | geojson.GeometryCollection
2226 | undefined;
2227}
2228
2229/**
2230 * Create a layer group, optionally given an initial set of layers and an `options` object.
2231 */
2232export function layerGroup<P = any>(layers?: Layer[], options?: LayerOptions): LayerGroup<P>;
2233
2234/**
2235 * Extended LayerGroup that also has mouse events (propagated from
2236 * members of the group) and a shared bindPopup method.
2237 */
2238export class FeatureGroup<P = any> extends LayerGroup<P> {
2239 /**
2240 * Adds the given layer to the group.
2241 */
2242 addLayer(layer: Layer): this;
2243
2244 /**
2245 * Removes the layer with the given internal ID or the given layer from the group.
2246 */
2247 removeLayer(layer: number | Layer): this;
2248
2249 /**
2250 * Sets the given path options to each layer of the group that has a setStyle method.
2251 */
2252 setStyle(style: PathOptions): this;
2253
2254 /**
2255 * Brings the layer group to the top of all other layers
2256 */
2257 bringToFront(): this;
2258
2259 /**
2260 * Brings the layer group to the top [sic] of all other layers
2261 */
2262 bringToBack(): this;
2263
2264 /**
2265 * Returns the LatLngBounds of the Feature Group (created from
2266 * bounds and coordinates of its children).
2267 */
2268 getBounds(): LatLngBounds;
2269}
2270
2271/**
2272 * Create a feature group, optionally given an initial set of layers.
2273 */
2274export function featureGroup<P = any>(layers?: Layer[], options?: LayerOptions): FeatureGroup<P>;
2275
2276export type StyleFunction<P = any> = (feature?: geojson.Feature<geojson.GeometryObject, P>) => PathOptions;
2277
2278export interface GeoJSONOptions<P = any, G extends geojson.GeometryObject = geojson.GeometryObject>
2279 extends InteractiveLayerOptions
2280{
2281 /**
2282 * A Function defining how GeoJSON points spawn Leaflet layers.
2283 * It is internally called when data is added, passing the GeoJSON point
2284 * feature and its LatLng.
2285 *
2286 * The default is to spawn a default Marker:
2287 *
2288 * ```
2289 * function(geoJsonPoint, latlng) {
2290 * return L.marker(latlng);
2291 * }
2292 * ```
2293 */
2294 pointToLayer?(geoJsonPoint: geojson.Feature<geojson.Point, P>, latlng: LatLng): Layer; // should import GeoJSON typings
2295
2296 /**
2297 * PathOptions or a Function defining the Path options for styling GeoJSON lines and polygons,
2298 * called internally when data is added.
2299 *
2300 * The default value is to not override any defaults:
2301 *
2302 * ```
2303 * function (geoJsonFeature) {
2304 * return {}
2305 * }
2306 * ```
2307 */
2308 style?: PathOptions | StyleFunction<P> | undefined;
2309
2310 /**
2311 * A Function that will be called once for each created Feature, after it
2312 * has been created and styled. Useful for attaching events and popups to features.
2313 *
2314 * The default is to do nothing with the newly created layers:
2315 *
2316 * ```
2317 * function (feature, layer) {}
2318 * ```
2319 */
2320 onEachFeature?(feature: geojson.Feature<G, P>, layer: Layer): void;
2321
2322 /**
2323 * A Function that will be used to decide whether to show a feature or not.
2324 *
2325 * The default is to show all features:
2326 *
2327 * ```
2328 * function (geoJsonFeature) {
2329 * return true;
2330 * }
2331 * ```
2332 */
2333 filter?(geoJsonFeature: geojson.Feature<G, P>): boolean;
2334
2335 /**
2336 * A Function that will be used for converting GeoJSON coordinates to LatLngs.
2337 * The default is the coordsToLatLng static method.
2338 */
2339 coordsToLatLng?(coords: [number, number] | [number, number, number]): LatLng; // check if LatLng has an altitude property
2340
2341 /** Whether default Markers for "Point" type Features inherit from group options. */
2342 markersInheritOptions?: boolean | undefined;
2343}
2344
2345/**
2346 * Represents a GeoJSON object or an array of GeoJSON objects.
2347 * Allows you to parse GeoJSON data and display it on the map. Extends FeatureGroup.
2348 */
2349export class GeoJSON<P = any, G extends geojson.GeometryObject = geojson.GeometryObject> extends FeatureGroup<P> {
2350 /**
2351 * Convert layer into GeoJSON feature
2352 */
2353 static getFeature<P = any, G extends geojson.GeometryObject = geojson.GeometryObject>(
2354 layer: Layer,
2355 newGeometry: geojson.Feature<G, P> | G,
2356 ): geojson.Feature<G, P>;
2357
2358 /**
2359 * Creates a Layer from a given GeoJSON feature. Can use a custom pointToLayer
2360 * and/or coordsToLatLng functions if provided as options.
2361 */
2362 static geometryToLayer<P = any, G extends geojson.GeometryObject = geojson.GeometryObject>(
2363 featureData: geojson.Feature<G, P>,
2364 options?: GeoJSONOptions<P, G>,
2365 ): Layer;
2366
2367 /**
2368 * Creates a LatLng object from an array of 2 numbers (longitude, latitude) or
2369 * 3 numbers (longitude, latitude, altitude) used in GeoJSON for points.
2370 */
2371 static coordsToLatLng(coords: [number, number] | [number, number, number]): LatLng;
2372
2373 /**
2374 * Creates a multidimensional array of LatLngs from a GeoJSON coordinates array.
2375 * levelsDeep specifies the nesting level (0 is for an array of points, 1 for an array of
2376 * arrays of points, etc., 0 by default).
2377 * Can use a custom coordsToLatLng function.
2378 */
2379 static coordsToLatLngs(
2380 coords: any[],
2381 levelsDeep?: number,
2382 coordsToLatLng?: (coords: [number, number] | [number, number, number]) => LatLng,
2383 ): any[]; // Using any[] to avoid artificially limiting valid calls
2384
2385 /**
2386 * Reverse of coordsToLatLng
2387 */
2388 static latLngToCoords(latlng: LatLng): [number, number] | [number, number, number];
2389
2390 /**
2391 * Reverse of coordsToLatLngs closed determines whether the first point should be
2392 * appended to the end of the array to close the feature, only used when levelsDeep is 0.
2393 * False by default.
2394 */
2395 static latLngsToCoords(latlngs: any[], levelsDeep?: number, closed?: boolean): any[]; // Using any[] to avoid artificially limiting valid calls
2396
2397 /**
2398 * Normalize GeoJSON geometries/features into GeoJSON features.
2399 */
2400 static asFeature<P = any, G extends geojson.GeometryObject = geojson.GeometryObject>(
2401 geojson: geojson.Feature<G, P> | G,
2402 ): geojson.Feature<G, P>;
2403
2404 constructor(geojson?: geojson.GeoJsonObject | null, options?: GeoJSONOptions<P, G> | null);
2405 /**
2406 * Adds a GeoJSON object to the layer.
2407 */
2408 addData(data: geojson.GeoJsonObject): this;
2409
2410 /**
2411 * Resets the given vector layer's style to the original GeoJSON style,
2412 * useful for resetting style after hover events.
2413 */
2414 resetStyle(layer?: Layer): this;
2415
2416 /**
2417 * Same as FeatureGroup's setStyle method, but style-functions are also
2418 * allowed here to set the style according to the feature.
2419 */
2420 setStyle(style: PathOptions | StyleFunction<P>): this;
2421
2422 options: GeoJSONOptions<P, G>;
2423}
2424
2425/**
2426 * Creates a GeoJSON layer.
2427 *
2428 * Optionally accepts an object in GeoJSON format to display on the
2429 * map (you can alternatively add it later with addData method) and
2430 * an options object.
2431 */
2432export function geoJSON<P = any, G extends geojson.GeometryObject = geojson.GeometryObject>(
2433 geojson?: geojson.GeoJsonObject | geojson.GeoJsonObject[] | null,
2434 options?: GeoJSONOptions<P, G> | null,
2435): GeoJSON<P, G>;
2436export function geoJson<P = any, G extends geojson.GeometryObject = geojson.GeometryObject>(
2437 geojson?: geojson.GeoJsonObject | geojson.GeoJsonObject[] | null,
2438 options?: GeoJSONOptions<P, G> | null,
2439): GeoJSON<P, G>;
2440
2441export type Zoom = boolean | "center";
2442
2443export interface MapOptions {
2444 preferCanvas?: boolean | undefined;
2445
2446 // Control options
2447 attributionControl?: boolean | undefined;
2448 zoomControl?: boolean | undefined;
2449
2450 // Interaction options
2451 closePopupOnClick?: boolean | undefined;
2452 zoomSnap?: number | undefined;
2453 zoomDelta?: number | undefined;
2454 trackResize?: boolean | undefined;
2455 boxZoom?: boolean | undefined;
2456 doubleClickZoom?: Zoom | undefined;
2457 dragging?: boolean | undefined;
2458
2459 // Map state options
2460 crs?: CRS | undefined;
2461 center?: LatLngExpression | undefined;
2462 zoom?: number | undefined;
2463 minZoom?: number | undefined;
2464 maxZoom?: number | undefined;
2465 layers?: Layer[] | undefined;
2466 maxBounds?: LatLngBoundsExpression | undefined;
2467 renderer?: Renderer | undefined;
2468
2469 // Animation options
2470 fadeAnimation?: boolean | undefined;
2471 markerZoomAnimation?: boolean | undefined;
2472 transform3DLimit?: number | undefined;
2473 zoomAnimation?: boolean | undefined;
2474 zoomAnimationThreshold?: number | undefined;
2475
2476 // Panning inertia options
2477 inertia?: boolean | undefined;
2478 inertiaDeceleration?: number | undefined;
2479 inertiaMaxSpeed?: number | undefined;
2480 easeLinearity?: number | undefined;
2481 worldCopyJump?: boolean | undefined;
2482 maxBoundsViscosity?: number | undefined;
2483
2484 // Keyboard navigation options
2485 keyboard?: boolean | undefined;
2486 keyboardPanDelta?: number | undefined;
2487
2488 // Mousewheel options
2489 scrollWheelZoom?: Zoom | undefined;
2490 wheelDebounceTime?: number | undefined;
2491 wheelPxPerZoomLevel?: number | undefined;
2492
2493 // Touch interaction options
2494 tap?: boolean | undefined;
2495 tapTolerance?: number | undefined;
2496 touchZoom?: Zoom | undefined;
2497 bounceAtZoomLimits?: boolean | undefined;
2498}
2499
2500export type ControlPosition = "topleft" | "topright" | "bottomleft" | "bottomright";
2501
2502export interface ControlOptions {
2503 position?: ControlPosition | undefined;
2504}
2505
2506export class Control extends Class {
2507 static extend<T extends object>(props: T): { new(...args: any[]): T } & typeof Control;
2508 constructor(options?: ControlOptions);
2509 getPosition(): ControlPosition;
2510 setPosition(position: ControlPosition): this;
2511 getContainer(): HTMLElement | undefined;
2512 addTo(map: Map): this;
2513 remove(): this;
2514
2515 // Extension methods
2516 onAdd?(map: Map): HTMLElement;
2517 onRemove?(map: Map): void;
2518
2519 options: ControlOptions;
2520}
2521
2522export namespace Control {
2523 interface ZoomOptions extends ControlOptions {
2524 zoomInText?: string | undefined;
2525 zoomInTitle?: string | undefined;
2526 zoomOutText?: string | undefined;
2527 zoomOutTitle?: string | undefined;
2528 }
2529
2530 class Zoom extends Control {
2531 constructor(options?: ZoomOptions);
2532 options: ZoomOptions;
2533 }
2534
2535 interface AttributionOptions extends ControlOptions {
2536 prefix?: string | boolean | undefined;
2537 }
2538
2539 class Attribution extends Control {
2540 constructor(options?: AttributionOptions);
2541 setPrefix(prefix: string | false): this;
2542 addAttribution(text: string): this;
2543 removeAttribution(text: string): this;
2544 options: AttributionOptions;
2545 }
2546
2547 interface LayersOptions extends ControlOptions {
2548 collapsed?: boolean | undefined;
2549 autoZIndex?: boolean | undefined;
2550 hideSingleBase?: boolean | undefined;
2551 /**
2552 * Whether to sort the layers. When `false`, layers will keep the order in which they were added to the control.
2553 */
2554 sortLayers?: boolean | undefined;
2555 /**
2556 * A [compare function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/sort)
2557 * that will be used for sorting the layers, when `sortLayers` is `true`. The function receives both the
2558 * [`L.Layer`](https://leafletjs.com/reference.html#layer) instances and their names, as in
2559 * `sortFunction(layerA, layerB, nameA, nameB)`. By default, it sorts layers alphabetically by their name.
2560 */
2561 sortFunction?: ((layerA: Layer, layerB: Layer, nameA: string, nameB: string) => number) | undefined;
2562 }
2563
2564 interface LayersObject {
2565 [name: string]: Layer;
2566 }
2567
2568 class Layers extends Control {
2569 constructor(baseLayers?: LayersObject, overlays?: LayersObject, options?: LayersOptions);
2570 addBaseLayer(layer: Layer, name: string): this;
2571 addOverlay(layer: Layer, name: string): this;
2572 removeLayer(layer: Layer): this;
2573 expand(): this;
2574 collapse(): this;
2575 options: LayersOptions;
2576 }
2577
2578 interface ScaleOptions extends ControlOptions {
2579 maxWidth?: number | undefined;
2580 metric?: boolean | undefined;
2581 imperial?: boolean | undefined;
2582 updateWhenIdle?: boolean | undefined;
2583 }
2584
2585 class Scale extends Control {
2586 constructor(options?: ScaleOptions);
2587 options: ScaleOptions;
2588 }
2589}
2590
2591export namespace control {
2592 function zoom(options?: Control.ZoomOptions): Control.Zoom;
2593
2594 function attribution(options?: Control.AttributionOptions): Control.Attribution;
2595
2596 function layers(
2597 baseLayers?: Control.LayersObject,
2598 overlays?: Control.LayersObject,
2599 options?: Control.LayersOptions,
2600 ): Control.Layers;
2601
2602 function scale(options?: Control.ScaleOptions): Control.Scale;
2603}
2604
2605export interface DivOverlayOptions {
2606 offset?: PointExpression | undefined;
2607 className?: string | undefined;
2608 pane?: string | undefined;
2609 interactive?: boolean | undefined;
2610 content?: string | HTMLElement | ((layer: Layer) => string) | ((layer: Layer) => HTMLElement);
2611}
2612
2613export abstract class DivOverlay extends Layer {
2614 constructor(latlng: LatLngExpression, options?: TooltipOptions);
2615 constructor(options?: DivOverlayOptions, source?: Layer);
2616 getLatLng(): LatLng | undefined;
2617 setLatLng(latlng: LatLngExpression): this;
2618 getContent(): Content | ((source: Layer) => Content) | undefined;
2619 setContent(htmlContent: ((source: Layer) => Content) | Content): this;
2620 getElement(): HTMLElement | undefined;
2621 update(): void;
2622 isOpen(): boolean;
2623 bringToFront(): this;
2624 bringToBack(): this;
2625 openOn(map: Map): this;
2626 toggle(layer?: Layer): this;
2627 close(): this;
2628
2629 options: DivOverlayOptions;
2630}
2631
2632export interface PopupOptions extends DivOverlayOptions {
2633 maxWidth?: number | undefined;
2634 minWidth?: number | undefined;
2635 maxHeight?: number | undefined;
2636 keepInView?: boolean | undefined;
2637 closeButton?: boolean | undefined;
2638 autoPan?: boolean | undefined;
2639 autoPanPaddingTopLeft?: PointExpression | undefined;
2640 autoPanPaddingBottomRight?: PointExpression | undefined;
2641 autoPanPadding?: PointExpression | undefined;
2642 autoClose?: boolean | undefined;
2643 closeOnClick?: boolean | undefined;
2644 closeOnEscapeKey?: boolean | undefined;
2645}
2646
2647export type Content = string | HTMLElement;
2648
2649export class Popup extends DivOverlay {
2650 constructor(latlng: LatLngExpression, options?: TooltipOptions);
2651 constructor(options?: PopupOptions, source?: Layer);
2652 openOn(map: Map): this;
2653
2654 options: PopupOptions;
2655}
2656
2657export function popup(options?: PopupOptions, source?: Layer): Popup;
2658
2659export type Direction = "right" | "left" | "top" | "bottom" | "center" | "auto";
2660
2661export interface TooltipOptions extends DivOverlayOptions {
2662 pane?: string | undefined;
2663 offset?: PointExpression | undefined;
2664 direction?: Direction | undefined;
2665 permanent?: boolean | undefined;
2666 sticky?: boolean | undefined;
2667 opacity?: number | undefined;
2668}
2669
2670export class Tooltip extends DivOverlay {
2671 constructor(latlng: LatLngExpression, options?: TooltipOptions);
2672 constructor(options?: TooltipOptions, source?: Layer);
2673 setOpacity(val: number): void;
2674
2675 options: TooltipOptions;
2676}
2677
2678export function tooltip(options?: TooltipOptions, source?: Layer): Tooltip;
2679
2680export interface ZoomOptions {
2681 animate?: boolean | undefined;
2682}
2683
2684export interface PanOptions {
2685 animate?: boolean | undefined;
2686 duration?: number | undefined;
2687 easeLinearity?: number | undefined;
2688 noMoveStart?: boolean | undefined;
2689}
2690
2691// This is not empty, it extends two interfaces into one...
2692export interface ZoomPanOptions extends ZoomOptions, PanOptions {}
2693
2694export interface InvalidateSizeOptions extends ZoomPanOptions {
2695 debounceMoveend?: boolean | undefined;
2696 pan?: boolean | undefined;
2697}
2698
2699export interface FitBoundsOptions extends ZoomOptions, PanOptions {
2700 paddingTopLeft?: PointExpression | undefined;
2701 paddingBottomRight?: PointExpression | undefined;
2702 padding?: PointExpression | undefined;
2703 maxZoom?: number | undefined;
2704}
2705
2706export interface PanInsideOptions extends PanOptions {
2707 paddingTopLeft?: PointExpression | undefined;
2708 paddingBottomRight?: PointExpression | undefined;
2709 padding?: PointExpression | undefined;
2710}
2711
2712export interface LocateOptions {
2713 watch?: boolean | undefined;
2714 setView?: boolean | undefined;
2715 maxZoom?: number | undefined;
2716 timeout?: number | undefined;
2717 maximumAge?: number | undefined;
2718 enableHighAccuracy?: boolean | undefined;
2719}
2720
2721export class Handler extends Class {
2722 constructor(map: Map);
2723 enable(): this;
2724 disable(): this;
2725 enabled(): boolean;
2726
2727 // Extension methods
2728 addHooks?(): void;
2729 removeHooks?(): void;
2730}
2731
2732export interface LeafletEvent {
2733 type: string;
2734 popup: any;
2735 target: any;
2736 sourceTarget: any;
2737 propagatedFrom: any;
2738 /**
2739 * @deprecated The same as {@link LeafletEvent.propagatedFrom propagatedFrom}.
2740 */
2741 layer: any;
2742}
2743
2744export interface LeafletMouseEvent extends LeafletEvent {
2745 latlng: LatLng;
2746 layerPoint: Point;
2747 containerPoint: Point;
2748 originalEvent: MouseEvent;
2749}
2750
2751export interface LeafletKeyboardEvent extends LeafletEvent {
2752 originalEvent: KeyboardEvent;
2753}
2754
2755export interface LocationEvent extends LeafletEvent {
2756 latlng: LatLng;
2757 bounds: LatLngBounds;
2758 accuracy: number;
2759 altitude: number;
2760 altitudeAccuracy: number;
2761 heading: number;
2762 speed: number;
2763 timestamp: number;
2764}
2765
2766export interface ErrorEvent extends LeafletEvent {
2767 message: string;
2768 code: number;
2769}
2770
2771export interface LayerEvent extends LeafletEvent {
2772 layer: Layer;
2773}
2774
2775export interface LayersControlEvent extends LayerEvent {
2776 name: string;
2777}
2778
2779export interface TileEvent extends LeafletEvent {
2780 tile: HTMLImageElement;
2781 coords: Coords;
2782}
2783
2784export interface TileErrorEvent extends TileEvent {
2785 error: Error;
2786}
2787
2788export interface ResizeEvent extends LeafletEvent {
2789 oldSize: Point;
2790 newSize: Point;
2791}
2792
2793export interface GeoJSONEvent extends LeafletEvent {
2794 layer: Layer;
2795 properties: any;
2796 geometryType: string;
2797 id: string;
2798}
2799
2800export interface PopupEvent extends LeafletEvent {
2801 popup: Popup;
2802}
2803
2804export interface TooltipEvent extends LeafletEvent {
2805 tooltip: Tooltip;
2806}
2807
2808export interface DragEndEvent extends LeafletEvent {
2809 distance: number;
2810}
2811
2812export interface ZoomAnimEvent extends LeafletEvent {
2813 center: LatLng;
2814 zoom: number;
2815 noUpdate: boolean;
2816}
2817
2818export namespace DomEvent {
2819 type EventHandlerFn = (event: Event) => void;
2820
2821 type PropagableEvent = LeafletMouseEvent | LeafletKeyboardEvent | LeafletEvent | Event;
2822
2823 function on(el: HTMLElement, types: string, fn: EventHandlerFn, context?: any): typeof DomEvent;
2824
2825 function on(el: HTMLElement, eventMap: { [eventName: string]: EventHandlerFn }, context?: any): typeof DomEvent;
2826
2827 // tslint:disable:unified-signatures
2828 function off(el: HTMLElement): typeof DomEvent;
2829
2830 function off(el: HTMLElement, types: string, fn: EventHandlerFn, context?: any): typeof DomEvent;
2831
2832 function off(el: HTMLElement, eventMap: { [eventName: string]: EventHandlerFn }, context?: any): typeof DomEvent;
2833 // tslint:enable:unified-signatures
2834
2835 function stopPropagation(ev: PropagableEvent): typeof DomEvent;
2836
2837 function disableScrollPropagation(el: HTMLElement): typeof DomEvent;
2838
2839 function disableClickPropagation(el: HTMLElement): typeof DomEvent;
2840
2841 function preventDefault(ev: Event): typeof DomEvent;
2842
2843 function stop(ev: PropagableEvent): typeof DomEvent;
2844
2845 function getMousePosition(ev: MouseEvent, container?: HTMLElement): Point;
2846
2847 function getWheelDelta(ev: Event): number;
2848
2849 function addListener(el: HTMLElement, types: string, fn: EventHandlerFn, context?: any): typeof DomEvent;
2850
2851 function addListener(
2852 el: HTMLElement,
2853 eventMap: { [eventName: string]: EventHandlerFn },
2854 context?: any,
2855 ): typeof DomEvent;
2856
2857 function removeListener(el: HTMLElement, types: string, fn: EventHandlerFn, context?: any): typeof DomEvent;
2858
2859 function removeListener(
2860 el: HTMLElement,
2861 eventMap: { [eventName: string]: EventHandlerFn },
2862 context?: any,
2863 ): typeof DomEvent;
2864
2865 function getPropagationPath(ev: Event): HTMLElement[];
2866}
2867
2868export interface DefaultMapPanes {
2869 mapPane: HTMLElement;
2870 tilePane: HTMLElement;
2871 overlayPane: HTMLElement;
2872 shadowPane: HTMLElement;
2873 markerPane: HTMLElement;
2874 tooltipPane: HTMLElement;
2875 popupPane: HTMLElement;
2876}
2877
2878export class Map extends Evented {
2879 constructor(element: string | HTMLElement, options?: MapOptions);
2880 getRenderer(layer: Path): Renderer;
2881
2882 // Methods for layers and controls
2883 addControl(control: Control): this;
2884 removeControl(control: Control): this;
2885 addLayer(layer: Layer): this;
2886 removeLayer(layer: Layer): this;
2887 hasLayer(layer: Layer): boolean;
2888 eachLayer(fn: (layer: Layer) => void, context?: any): this;
2889 openPopup(popup: Popup): this;
2890 openPopup(content: Content, latlng: LatLngExpression, options?: PopupOptions): this;
2891 closePopup(popup?: Popup): this;
2892 openTooltip(tooltip: Tooltip): this;
2893 openTooltip(content: Content, latlng: LatLngExpression, options?: TooltipOptions): this;
2894 closeTooltip(tooltip?: Tooltip): this;
2895
2896 // Methods for modifying map state
2897 setView(center: LatLngExpression, zoom?: number, options?: ZoomPanOptions): this;
2898 setZoom(zoom: number, options?: ZoomPanOptions): this;
2899 zoomIn(delta?: number, options?: ZoomOptions): this;
2900 zoomOut(delta?: number, options?: ZoomOptions): this;
2901 setZoomAround(position: Point | LatLngExpression, zoom: number, options?: ZoomOptions): this;
2902 fitBounds(bounds: LatLngBoundsExpression, options?: FitBoundsOptions): this;
2903 fitWorld(options?: FitBoundsOptions): this;
2904 panTo(latlng: LatLngExpression, options?: PanOptions): this;
2905 panBy(offset: PointExpression, options?: PanOptions): this;
2906 setMaxBounds(bounds: LatLngBoundsExpression): this;
2907 setMinZoom(zoom: number): this;
2908 setMaxZoom(zoom: number): this;
2909 panInside(latLng: LatLngExpression, options?: PanInsideOptions): this;
2910 panInsideBounds(bounds: LatLngBoundsExpression, options?: PanOptions): this;
2911 /**
2912 * Boolean for animate or advanced ZoomPanOptions
2913 */
2914 invalidateSize(options?: boolean | InvalidateSizeOptions): this;
2915 stop(): this;
2916 flyTo(latlng: LatLngExpression, zoom?: number, options?: ZoomPanOptions): this;
2917 flyToBounds(bounds: LatLngBoundsExpression, options?: FitBoundsOptions): this;
2918
2919 // Other methods
2920 addHandler(name: string, HandlerClass: typeof Handler): this; // Alternatively, HandlerClass: new(map: Map) => Handler
2921 remove(): this;
2922 createPane(name: string, container?: HTMLElement): HTMLElement;
2923 /**
2924 * Name of the pane or the pane as HTML-Element
2925 */
2926 getPane(pane: string | HTMLElement): HTMLElement | undefined;
2927 getPanes(): { [name: string]: HTMLElement } & DefaultMapPanes;
2928 getContainer(): HTMLElement;
2929 whenReady(fn: () => void, context?: any): this;
2930
2931 // Methods for getting map state
2932 getCenter(): LatLng;
2933 getZoom(): number;
2934 getBounds(): LatLngBounds;
2935 getMinZoom(): number;
2936 getMaxZoom(): number;
2937 getBoundsZoom(bounds: LatLngBoundsExpression, inside?: boolean, padding?: Point): number;
2938 getSize(): Point;
2939 getPixelBounds(): Bounds;
2940 getPixelOrigin(): Point;
2941 getPixelWorldBounds(zoom?: number): Bounds;
2942
2943 // Conversion methods
2944 getZoomScale(toZoom: number, fromZoom?: number): number;
2945 getScaleZoom(scale: number, fromZoom?: number): number;
2946 project(latlng: LatLngExpression, zoom?: number): Point;
2947 unproject(point: PointExpression, zoom?: number): LatLng;
2948 layerPointToLatLng(point: PointExpression): LatLng;
2949 latLngToLayerPoint(latlng: LatLngExpression): Point;
2950 wrapLatLng(latlng: LatLngExpression): LatLng;
2951 wrapLatLngBounds(bounds: LatLngBounds): LatLngBounds;
2952 distance(latlng1: LatLngExpression, latlng2: LatLngExpression): number;
2953 containerPointToLayerPoint(point: PointExpression): Point;
2954 containerPointToLatLng(point: PointExpression): LatLng;
2955 layerPointToContainerPoint(point: PointExpression): Point;
2956 latLngToContainerPoint(latlng: LatLngExpression): Point;
2957 mouseEventToContainerPoint(ev: MouseEvent): Point;
2958 mouseEventToLayerPoint(ev: MouseEvent): Point;
2959 mouseEventToLatLng(ev: MouseEvent): LatLng;
2960
2961 // Geolocation methods
2962 locate(options?: LocateOptions): this;
2963 stopLocate(): this;
2964
2965 // Properties
2966 attributionControl: L.Control.Attribution;
2967 boxZoom: Handler;
2968 doubleClickZoom: Handler;
2969 dragging: Handler;
2970 keyboard: Handler;
2971 scrollWheelZoom: Handler;
2972 tap?: Handler | undefined;
2973 touchZoom: Handler;
2974 zoomControl: Control.Zoom;
2975
2976 options: MapOptions;
2977}
2978
2979/**
2980 * ID of a HTML-Element as string or the HTML-ELement itself
2981 */
2982export function map(element: string | HTMLElement, options?: MapOptions): Map;
2983
2984export interface BaseIconOptions extends LayerOptions {
2985 iconUrl?: string | undefined;
2986 iconRetinaUrl?: string | undefined;
2987 iconSize?: PointExpression | undefined;
2988 iconAnchor?: PointExpression | undefined;
2989 popupAnchor?: PointExpression | undefined;
2990 tooltipAnchor?: PointExpression | undefined;
2991 shadowUrl?: string | undefined;
2992 shadowRetinaUrl?: string | undefined;
2993 shadowSize?: PointExpression | undefined;
2994 shadowAnchor?: PointExpression | undefined;
2995 className?: string | undefined;
2996}
2997
2998export interface IconOptions extends BaseIconOptions {
2999 iconUrl: string;
3000 crossOrigin?: CrossOrigin | boolean | undefined;
3001}
3002
3003export class Icon<T extends BaseIconOptions = IconOptions> extends Layer {
3004 constructor(options: T);
3005 createIcon(oldIcon?: HTMLElement): HTMLElement;
3006 createShadow(oldIcon?: HTMLElement): HTMLElement;
3007
3008 options: T;
3009}
3010
3011export namespace Icon {
3012 interface DefaultIconOptions extends BaseIconOptions {
3013 imagePath?: string | undefined;
3014 }
3015
3016 class Default extends Icon<DefaultIconOptions> {
3017 static imagePath?: string | undefined;
3018 constructor(options?: DefaultIconOptions);
3019 }
3020}
3021
3022export function icon(options: IconOptions): Icon;
3023
3024export interface DivIconOptions extends BaseIconOptions {
3025 html?: string | HTMLElement | false | undefined;
3026 bgPos?: PointExpression | undefined;
3027 iconSize?: PointExpression | undefined;
3028 iconAnchor?: PointExpression | undefined;
3029 popupAnchor?: PointExpression | undefined;
3030 className?: string | undefined;
3031}
3032
3033export class DivIcon extends Icon<DivIconOptions> {
3034 constructor(options?: DivIconOptions);
3035}
3036
3037export function divIcon(options?: DivIconOptions): DivIcon;
3038
3039export interface MarkerOptions extends InteractiveLayerOptions {
3040 icon?: Icon | DivIcon | undefined;
3041 /** Whether the marker is draggable with mouse/touch or not. */
3042 draggable?: boolean | undefined;
3043 /** Whether the marker can be tabbed to with a keyboard and clicked by pressing enter. */
3044 keyboard?: boolean | undefined;
3045 /** Text for the browser tooltip that appear on marker hover (no tooltip by default). */
3046 title?: string | undefined;
3047 /** Text for the `alt` attribute of the icon image (useful for accessibility). */
3048 alt?: string | undefined;
3049 /** Option for putting the marker on top of all others (or below). */
3050 zIndexOffset?: number | undefined;
3051 /** The opacity of the marker. */
3052 opacity?: number | undefined;
3053 /** If `true`, the marker will get on top of others when you hover the mouse over it. */
3054 riseOnHover?: boolean | undefined;
3055 /** The z-index offset used for the `riseOnHover` feature. */
3056 riseOffset?: number | undefined;
3057 /** `Map pane` where the markers shadow will be added. */
3058 shadowPane?: string | undefined;
3059 /** Whether to pan the map when dragging this marker near its edge or not. */
3060 autoPan?: boolean | undefined;
3061 /** Distance (in pixels to the left/right and to the top/bottom) of the map edge to start panning the map. */
3062 autoPanPadding?: PointExpression | undefined;
3063 /** Number of pixels the map should pan by. */
3064 autoPanSpeed?: number | undefined;
3065 autoPanOnFocus?: boolean | undefined;
3066}
3067
3068export class Marker<P = any> extends Layer {
3069 constructor(latlng: LatLngExpression, options?: MarkerOptions);
3070 toGeoJSON(precision?: number | false): geojson.Feature<geojson.Point, P>;
3071 getLatLng(): LatLng;
3072 setLatLng(latlng: LatLngExpression): this;
3073 setZIndexOffset(offset: number): this;
3074 getIcon(): Icon | DivIcon;
3075 setIcon(icon: Icon | DivIcon): this;
3076 setOpacity(opacity: number): this;
3077 getElement(): HTMLElement | undefined;
3078
3079 // Properties
3080 options: MarkerOptions;
3081 dragging?: Handler | undefined;
3082 feature?: geojson.Feature<geojson.Point, P> | undefined;
3083
3084 protected _shadow: HTMLElement | undefined;
3085}
3086
3087export function marker<P = any>(latlng: LatLngExpression, options?: MarkerOptions): Marker<P>;
3088
3089export namespace Browser {
3090 // sorting according to https://leafletjs.com/reference-1.5.0.html#browser
3091 const ie: boolean;
3092 const ielt9: boolean;
3093 const edge: boolean;
3094 const webkit: boolean;
3095 const android: boolean;
3096 const android23: boolean;
3097 const androidStock: boolean;
3098 const opera: boolean;
3099 const chrome: boolean;
3100 const gecko: boolean;
3101 const safari: boolean;
3102 const opera12: boolean;
3103 const win: boolean;
3104 const ie3d: boolean;
3105 const webkit3d: boolean;
3106 const gecko3d: boolean;
3107 const any3d: boolean;
3108 const mobile: boolean;
3109 const mobileWebkit: boolean;
3110 const mobileWebkit3d: boolean;
3111 const msPointer: boolean;
3112 const pointer: boolean;
3113 const touch: boolean;
3114 const mobileOpera: boolean;
3115 const mobileGecko: boolean;
3116 const retina: boolean;
3117 const canvas: boolean;
3118 const svg: boolean;
3119 const vml: boolean;
3120}
3121
3122export namespace Util {
3123 function extend<D extends object, S1 extends object = {}>(dest: D, src?: S1): D & S1;
3124 function extend<D extends object, S1 extends object, S2 extends object>(dest: D, src1: S1, src2: S2): D & S1 & S2;
3125 function extend<D extends object, S1 extends object, S2 extends object, S3 extends object>(
3126 dest: D,
3127 src1: S1,
3128 src2: S2,
3129 src3: S3,
3130 ): D & S1 & S2 & S3;
3131 function extend(dest: any, ...src: any[]): any;
3132
3133 function create(proto: object | null, properties?: PropertyDescriptorMap): any;
3134 function bind(fn: (...args: any[]) => void, ...obj: any[]): () => void;
3135 function stamp(obj: any): number;
3136 function throttle(fn: () => void, time: number, context: any): () => void;
3137 function wrapNum(num: number, range: number[], includeMax?: boolean): number;
3138 function falseFn(): false;
3139 function formatNum(num: number, digits?: number | false): number;
3140 function trim(str: string): string;
3141 function splitWords(str: string): string[];
3142 function setOptions(obj: any, options: any): any;
3143 function getParamString(obj: any, existingUrl?: string, uppercase?: boolean): string;
3144 function template(str: string, data: any): string;
3145 function isArray(obj: any): boolean;
3146 function indexOf(array: any[], el: any): number;
3147 function requestAnimFrame(fn: (timestamp: number) => void, context?: any, immediate?: boolean): number;
3148 function cancelAnimFrame(id: number): void;
3149
3150 let lastId: number;
3151 let emptyImageUrl: string;
3152}
3153
3154export const extend: typeof Util["extend"];
3155export const bind: typeof Util["bind"];
3156export const stamp: typeof Util["stamp"];
3157export const setOptions: typeof Util["setOptions"];
3158
3159export function noConflict(): any;