UNPKG

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