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. ex: http://openlayers.org/dev/examples/click.html

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 OpenLayers helps to get the lat ,long values... looking for something similar using Leaflet...

| improve this question | | | | |

You can easily get click events using the map's 'on' event subscription method:

map.on('click', function(e) {
    alert("Lat, Lon : " + e.latlng.lat + ", " + e.latlng.lng)
| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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