Reputation: 332
I use this code :
L.control.layers(WMS, null, {collapsed: true}).addTo(mymap);
//WMS = group of wms layer
to add radio button in leaflet and I would like to know which button was selected to be able to execute overs JS functions.
Upvotes: 0
Views: 249
Reputation: 332
With jQuery I check if there is a click on the button like this :
$(".leaflet-control-layers-selector").on('click',function(){.....});
In the function I use the function map.eachLayer(....);
to execute different program on each layers.
Note : ".leaflet-control-layers-selector"
is the class generate by leaflet for the radio button.
Upvotes: 0
Reputation: 2618
You could use map.hasLayer(myLayer)
to test if a layer is added to the map.
Upvotes: 1