I'm working on a map using Leaflet.js that uses a number of markers (eventually there will be ~40 markers). Each marker has a related popup with details. The default behaviour of Leaflet.js seems to be to automatically open at least one marker's popup (the last listed marker, I believe).
I'd like all the popups to be closed on the initial loading of the map page so users have to click the markers to open the popups. Does anyone know how to do this? I have a prototype here:
http://dev.monographic.org/maps/prototype-10.html
Thank you.
There is a clean method from your map object to close all open popups
map.closePopup();
I managed to solve my problem by this piece of code:
$(".leaflet-popup-close-button")[0].click();
Hope it helps someone in future.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With