I want to toggle the Leaflet layer control when the user clicks in a button.
var layerControl = L.control.layers(
{
'<i class="fas fa-map-marked"></i>': OSM,
'<i class="fas fa-image"></i>': Esri_WorldImagery
}, null, {collapsed: false}
).addTo(map);
<button onclick="toggleLayerControl()">toggle control</button>
function toggleLayerControl(){
if(layerControl.display=="block"){
layerControl.display = "none";
}else{
layerControl.display = "block";
}
}
What's the simplest way of doing that?