Leaflet – How to Add a Popup Only on Click

leafletmarkerspopup

As there a way to add a popup to a marker but only show it when it is clicked?

As it seems to be default to show it when one is loaded. This is no good when markers are getting updated.

Currently using this

 mymarker = new L.Marker(e.latlng, {
                icon: yellowIcon,
               draggable: true
             });


             map.addLayer(mymarker);
             mymarker.bindPopup('<p>You are here ' + username + '</p>').openPopup();

Best Answer

Just leave out call of .openPopup() method:

mymarker.bindPopup('<p>You are here ' + username + '</p>');
Related Question