1

I am adding map styles in L.control.layers like this:

L.control.layers({
        'Mapbox Light': L.mapbox.tileLayer('mapbox.light',{name:"base"}),
        'S_S': L.mapbox.styleLayer('mapbox://styles/geotrek/s***',{name:"F1"}).addTo(map),
        'S_F': L.mapbox.styleLayer('mapbox://styles/f****',{name:"F2"})
    }, null).addTo(map);

I can get the layer name on change

 map.on('baselayerchange', function(l){
        console.log("baselayerchange",l);
        console.log("baselayerchange",l.layer.options);
        console.log("CONTROLS:", controls)
    })

How can I get the current layer style name like S_F or S_S or Mapbox Light or options name on map CLICK event?

1

You can use the Leaflet.ActiveLayers plugin to achieve that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.