Skip to content

Commit 46816bd

Browse files
committed
Leaflet: Add LeafletLayersControlEvent
1 parent 6f6e5c7 commit 46816bd

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
@@ -1835,6 +1835,22 @@ declare module L {
18351835
}
18361836
}
18371837

1838+
declare module L {
1839+
1840+
export interface LeafletLayersControlEvent extends LeafletEvent {
1841+
1842+
/**
1843+
* The layer that was added or removed.
1844+
*/
1845+
layer: ILayer;
1846+
1847+
/**
1848+
* The name of the layer that was added or removed.
1849+
*/
1850+
name: string;
1851+
}
1852+
}
1853+
18381854
declare module L {
18391855

18401856
export interface LeafletLocationEvent extends LeafletEvent {

0 commit comments

Comments
 (0)