How to get the name/ID of the current map layer in Leaflet?

How to get the name/ID of the current layer in Leaflet?
Tried it before, but ID dynamic:

map.on('baselayerchange', function(e){
alert(e.layer._leaflet_id);
});


The task is to identify and save the layer in a cookie.
April 19th 20 at 11:59
1 answer
April 19th 20 at 12:01
Solution

Find more questions by tags LeafletJavaScript