diff --git a/leaflet/index.d.ts b/leaflet/index.d.ts index c56e98e7f8..0d455717f2 100644 --- a/leaflet/index.d.ts +++ b/leaflet/index.d.ts @@ -390,7 +390,8 @@ declare namespace L { interactive?: boolean; } - export interface Layer extends Evented { + export class Layer extends Evented { + constructor(options?: LayerOptions); addTo(map: Map): this; remove(): this; removeFrom(map: Map): this; @@ -502,7 +503,7 @@ declare namespace L { } export namespace tileLayer { - export function wms(baseUrl: string, options: WMSOptions): WMS; + export function wms(baseUrl: string, options?: WMSOptions): WMS; } export interface ImageOverlayOptions extends LayerOptions { @@ -1247,12 +1248,12 @@ declare namespace L { // Methods for modifying map state setView(center: LatLngExpression, zoom: number, options?: ZoomPanOptions): this; - setZoom(zoom: number, options: ZoomPanOptions): this; + setZoom(zoom: number, options?: ZoomPanOptions): this; zoomIn(delta?: number, options?: ZoomOptions): this; zoomOut(delta?: number, options?: ZoomOptions): this; - setZoomAround(latlng: LatLngExpression, zoom: number, options: ZoomOptions): this; - setZoomAround(offset: Point, zoom: number, options: ZoomOptions): this; - fitBounds(bounds: LatLngBoundsExpression, options: FitBoundsOptions): this; + setZoomAround(latlng: LatLngExpression, zoom: number, options?: ZoomOptions): this; + setZoomAround(offset: Point, zoom: number, options?: ZoomOptions): this; + fitBounds(bounds: LatLngBoundsExpression, options?: FitBoundsOptions): this; fitWorld(options?: FitBoundsOptions): this; panTo(latlng: LatLngExpression, options?: PanOptions): this; panBy(offset: PointExpression): this; @@ -1345,8 +1346,15 @@ declare namespace L { imagePath: string; } + export class Icon { + constructor(options: IconOptions); + } + export namespace Icon { - export const Default: IconDefault; + export class Default extends Icon { + constructor(options?: IconOptions); + imagePath: string; + } } export function icon(options: IconOptions): Icon; @@ -1360,9 +1368,11 @@ declare namespace L { className?: string; } - export interface DivIcon extends Icon {} + export class DivIcon extends Icon { + constructor(options?: DivIconOptions); + } - export function divIcon(options: DivIconOptions): DivIcon; + export function divIcon(options?: DivIconOptions): DivIcon; export interface MarkerOptions extends InteractiveLayerOptions { icon?: Icon; @@ -1376,12 +1386,14 @@ declare namespace L { riseOffset?: number; } - export interface Marker extends Layer { + export class Marker extends Layer { + constructor(latlng: LatLngExpression, options?: MarkerOptions); getLatLng(): LatLng; setLatLng(latlng: LatLngExpression): this; setZIndexOffset(offset: number): this; setIcon(icon: Icon): this; setOpacity(opacity: number): this; + getElement(): Element; // Properties dragging: Handler; diff --git a/leaflet/leaflet-tests.ts b/leaflet/leaflet-tests.ts index 1d3f447ad4..8b988509c6 100644 --- a/leaflet/leaflet-tests.ts +++ b/leaflet/leaflet-tests.ts @@ -297,6 +297,7 @@ map = map .setView(latLngLiteral, 12, zoomPanOptions) .setView(latLngTuple, 12) .setView(latLngTuple, 12, zoomPanOptions) + .setZoom(11) .setZoom(12, zoomPanOptions) // investigate if zoomPanOptions are really required .zoomIn() .zoomIn(1) @@ -309,6 +310,7 @@ map = map .setZoomAround(latLngTuple, 12, zoomOptions) .setZoomAround(point, 12, zoomOptions) .setZoomAround(pointTuple, 11, zoomOptions) + .fitBounds(latLngBounds) .fitBounds(latLngBounds, fitBoundsOptions) // investigate if fit bounds options are really required .fitBounds(latLngBoundsLiteral, fitBoundsOptions) .fitWorld() @@ -354,4 +356,25 @@ let elementToDrag = document.createElement('div'); let draggable = new L.Draggable(elementToDrag); draggable.enable(); draggable.disable(); -draggable.on('drag', () => {}); \ No newline at end of file +draggable.on('drag', () => {}); + +class MyMarker extends L.Marker { + constructor() { + super([12, 13]); + } +} +class MyLayer extends L.Layer { + constructor() { + super(); + } +} +class MyIcon extends L.Icon { + constructor() { + super({iconUrl: 'icon.png'}); + } +} +class MyDivIcon extends L.DivIcon { + constructor() { + super(); + } +}