3

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();

1 Answer 1

9

Just leave out call of .openPopup() method:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.