UNPKG

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