diff --git a/types/leaflet/index.d.ts b/types/leaflet/index.d.ts index 8177ba1aa6..96bcb3277a 100644 --- a/types/leaflet/index.d.ts +++ b/types/leaflet/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Leaflet.js 1.2 +// Type definitions for Leaflet.js 1.4 // Project: https://github.com/Leaflet/Leaflet // Definitions by: Alejandro Sánchez // Arne Schubert @@ -323,7 +323,7 @@ export abstract class Evented extends Class { * Note that if you passed a custom context to on, you must pass the same context * to off in order to remove the listener. */ - removeEventListener(type: string, fn: LeafletEventHandlerFn, context?: any): this; + removeEventListener(type: string, fn?: LeafletEventHandlerFn, context?: any): this; /** * Alias for off(...) @@ -1181,6 +1181,12 @@ export interface FitBoundsOptions extends ZoomOptions, PanOptions { maxZoom?: number; } +export interface PanInsideOptions { + paddingTopLeft?: PointExpression; + paddingBottomRight?: PointExpression; + padding?: PointExpression; +} + export interface LocateOptions { watch?: boolean; setView?: boolean; @@ -1355,6 +1361,7 @@ export class Map extends Evented { setMaxBounds(bounds: LatLngBoundsExpression): this; setMinZoom(zoom: number): this; setMaxZoom(zoom: number): this; + panInside(latLng: LatLngExpression, options?: PanInsideOptions): this; panInsideBounds(bounds: LatLngBoundsExpression, options?: PanOptions): this; /** * Boolean for animate or advanced ZoomPanOptions diff --git a/types/leaflet/leaflet-tests.ts b/types/leaflet/leaflet-tests.ts index 6debf6b0d6..a6c9b6ccc3 100644 --- a/types/leaflet/leaflet-tests.ts +++ b/types/leaflet/leaflet-tests.ts @@ -40,8 +40,8 @@ point = new L.Point(12, 13); point = new L.Point(12, 13, true); let distance: number; -point.distanceTo(point); -point.distanceTo(pointTuple); +distance = point.distanceTo(point); +distance = point.distanceTo(pointTuple); const transformation = new L.Transformation(1, 2, 3, 4); point = transformation.transform(point); @@ -163,6 +163,16 @@ map = new L.Map(htmlElement, mapOptions); let doesItHaveLayer: boolean; doesItHaveLayer = map.hasLayer(L.tileLayer('')); +map.off('moveend'); +map.off('moveend', () => {}); +map.off('moveend', () => {}, {}); + +map.removeEventListener('moveend'); +map.removeEventListener('moveend', () => {}); +map.removeEventListener('moveend', () => {}, {}); + +map.panInside(latLng, {padding: [50, 50], paddingBottomRight: point, paddingTopLeft: [100, 100]}); + // map.getRenderer let html: HTMLElement;