Live map: How to prevent pop-up at load time?


This HTML + JavaScript page works fine to display waypoints in a live map, but when displayed, the last item pops up.

marker = L.marker([46.823576, -0.572421]).addTo(map);
marker.bindPopup("Item1<br />Desc1").openPopup();
marker = L.marker([53.192883, -1.432042]).addTo(map);
marker.bindPopup("Item2<br />Desc2").openPopup();

Is there a way to avoid this problem?

Besides, I’d like the map to be zoomed out intially, so as to view all waypoints.

Thank you.

Your question is about Leaflet, which is a Javascript framework to display items on top of a map.

To prevent the popup from opening, remove .openPopup() from this code.

var lat = 40.73;
var lon = -74.0;

// initialize map
map ="mapDiv").setView([lat, lon], 13);

you can change the lat lon and the “13” to place the map where you want

1 Like