I can manage my layers by the LayerSwitcher panel. The legend is created by HTML, and I post it on the site by:

Document.getElementById ("legend") style.display = "block";

What I want: When I check or I uncheck the layer, its legend will appear or disappear. How can I do that?

 var layerSwitcher = new ol.control.LayerSwitcher({
    tipLabel: 'Légende' // Optional label for button


  • LayerSwitcher was in OL2 but is not currently supported in OL3. See: gis.stackexchange.com/questions/119713/… – nmtoken Dec 18 '16 at 11:43
  • this question is asked in 2 years ago, and i use ol3 in the development of my site. how can i add a screenshot to show you? – Nora 27 Dec 18 '16 at 13:11
  • The question may be two years old, but the latest OL3 docs v3.20.0 still don't seem to have a layerswitcher control – nmtoken Dec 18 '16 at 18:44
  • thank you, may be what I use it is other than layerswitcher. – Nora 27 Dec 19 '16 at 8:59

Your Answer

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

Browse other questions tagged or ask your own question.