Leaflet.HtmlLegend icon indicating copy to clipboard operation
Leaflet.HtmlLegend copied to clipboard

allow disableVisibilityControls key for each legend entry

Open brentfraser opened this issue 6 years ago • 3 comments

brentfraser avatar Dec 05 '19 18:12 brentfraser

Can you elaborate more on this? Do you mean you'd like to be able to change the transparency of all the layers within a layer that is attached to a legend control? I'm afraid such a thing is beyond the scope of this plugin. Items in legend elements have no concept of which sub-layer they are representing.

ka7eh avatar Jan 12 '20 03:01 ka7eh

No. For some entries, I just use the control to show colors with description (see Layer 1 in your example site), but I don't want to have the show/hide symbol or the transparency control. I DO want the controls for the second layer (Layer 2 in your example).

Currently the disableVisibilityControls applies to all the entries in the legend. I would like to set it per entry.

One work-around would be to have separate legends, but that would clutter the map.

brentfraser avatar Jan 12 '20 15:01 brentfraser

I see what you mean. I updated the code and moved disableVisibilityControls to legend options. Now you can set that option to true for each legend that you don't want to have a visibility slider.

The new changes are in https://github.com/consbio/Leaflet.HtmlLegend/pull/13 and waiting for review. You can see its usage in layer 4 in the updated example.

ka7eh avatar Jan 12 '20 16:01 ka7eh