Skip to content

Commit 18052c0

Browse files
committed
Merge pull request DefinitelyTyped#5902 from rimig/leaflet-layercontrolevent
Leaflet: Add LeafletLayersControlEvent
2 parents 3f5aa57 + 46816bd commit 18052c0

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

leaflet/leaflet-tests.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,11 @@ map.closePopup();
148148
map.addControl(L.control.attribution({position: 'bottomright'}));
149149
map.removeControl(L.control.attribution({ position: 'bottomright' }));
150150

151+
L.control.layers({'Base': layer}).addTo(map);
152+
map.on('baseLayerChange', function(e: L.LeafletLayersControlEvent) {
153+
alert(e.name);
154+
});
155+
151156
map.latLngToLayerPoint(map.layerPointToLatLng(L.point(0, 0)));
152157
map.latLngToContainerPoint(map.containerPointToLatLng(L.point(0, 0)));
153158
map.containerPointToLayerPoint(L.point(0, 0));

leaflet/leaflet.d.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1838,6 +1838,22 @@ declare namespace L {
18381838

18391839
declare namespace L {
18401840

1841+
export interface LeafletLayersControlEvent extends LeafletEvent {
1842+
1843+
/**
1844+
* The layer that was added or removed.
1845+
*/
1846+
layer: ILayer;
1847+
1848+
/**
1849+
* The name of the layer that was added or removed.
1850+
*/
1851+
name: string;
1852+
}
1853+
}
1854+
1855+
declare module L {
1856+
18411857
export interface LeafletLocationEvent extends LeafletEvent {
18421858

18431859
/**

0 commit comments

Comments
 (0)