Leaflet – Solving Problems with Legends in Leaflet

javascriptleaflet

I am not very good at js and new with leaflet so i my code may be a bit messy but stil…
I have a problem with my legends, i have 2 legends and many overlays and i want some legends to be "linked" with some overlays.
I followed every example i saw but still i have a problem with the name of the layer, it's like my names don't work so controls can't change legends properly

I made a jsfiddle that can explains more obviously my problem. http://jsfiddle.net/qs6wkru4/3/

I want the legend to change when i click on "Cuivre" and not on others…

Best Answer

Your Leaflet-Version is 1.0dev. There the eventlayer.name is missing.

I also added a counter so see when the other legend has to be removed. Was this the functionality you were looking for?

http://jsfiddle.net/expedio/7LskL5e1/