How to get the Lat, Long of a clicked location using leaflet Api
10,157
map.on('click', function(e) {
alert(e.latlng);
});
![troy](https://i.stack.imgur.com/ZDrG1.gif?s=256&g=1)
Comments
-
troy about 2 years
I am using OSM with leaflet API. Now I want to get the lat and long of a clicked location. I meant something similar to this:
map.events.register("click", map, function(e) { var position = map.getLonLatFromPixel(e.xy); alert("Lat, Lon : "+position.lon.toFixed(3),position.lat.toFixed(3)); });
This code in open layers helps to get the lat,long values - looking for something similar using leaflet.
Any help would be really great. Thanks in advance
-
kcpr about 7 yearsJust remember about
e: L.MouseEvent
if You use TypeScript.