Show and hide Leaflet map on click button
-
Hello,
I don’t know if this is the correct forum where I have to ask, but I have the next problem:
I would like to insert some buttons in a new page, and depending on the button pressed, show a map.
Firstly, when you enter to the page, you only see the buttons, because the map would be inside a hide div.
The problem is the map is not loading well, as you can see in: https://imgur.com/VFPGkg4I have tested with some HTML and JS code:
I have a button, with ID and CLASS: but1.
<script> const button1 = document.getElementById('but1'); const map1 = document.getElementById('map1'); button1.addEventListener('click', function() { if(map1.style.display == 'none') { map1.style.display = 'block'; } else { map1.style.display = 'none'; } }); </script>
In the page I have added some HTML code, before [leaflet] map:
<div id="map1" style="display:none";>
And finally HTML code:
</div>
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘Show and hide Leaflet map on click button’ is closed to new replies.