[GIS] Layer switcher triggered by HTML button in OpenLayers

openlayers

in this code you have an example of layer switcher use in OpenLayers

https://rawgit.com/walkermatt/ol-layerswitcher/master/examples/layerswitcher.html

The button which triggers the action is written in .js using ol.control.LayerSwitcher, though.

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

What do I have to change if I want the same pop-up to be displayed, but by clicking the HTML icon in the "navbar" div of the site, not this button?

Best Answer

To display or hide from your own code use

layerSwitcher.showPanel();
layerSwitcher.hidePanel();