Reputation:
Code for popup onMouseClick, which shows lat & long
var popup = L.popup();
function onMapClick(e) {
popup
.setLatLng(e.latlng)
.setContent("You clicked the map at " + e.latlng.toString())
.openOn(mymap);
}
mymap.on('click', onMapClick);
Is it possible to add marker, i tried to put 'marker in function, but didn't work.
And how to get lat long differently, so i can copy it in two diff variables
Upvotes: 0
Views: 1923
Reputation: 805
i think you are expecting something like this
function onMapClick(e) {
new L.marker([e.latlng.lat,e.latlng.lng]).addTo(map).bindPopup("You clicked the map at " + e.latlng.toString()).openPopup();
}
Upvotes: 0