Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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 open layers helps to get the lat ,long values .... looking for something similar using leaflet........ Any help would be really great..... Thanks in advance

share|improve this question

3 Answers 3

up vote 4 down vote accepted

check out this example here may help you...

i have not used it before as you. it locates in Conversion Methods.

mouseEventToLatLng( event ) LatLng Returns the geographical coordinates of the point the mouse clicked on given the click's event object.

i hope it helps you...

share|improve this answer
    
Cheers.. this example helped me.... –  DomincJune Nov 1 '12 at 12:35

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)
}
share|improve this answer

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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