Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using the leaflet API with OSM. I need to implement a functionality where on dragging the marker and dropping it on user preferred location, I need to get its latitude and longitude and save its location to database.

For now on double clicking the marker I am able to drag the marker. This line helped me:


Now when I release the marker I want to find the latitude and longitude of the location or invoking a function on dragging the marker, returning the lat,lng values.

share|improve this question
Downvote: bad formatting, no respect for “no please in questions” guidelines, but most of all most basic research not done. – MattiSG Nov 5 '12 at 18:30
See also… – Kasper Souren Mar 25 '14 at 13:57
up vote 6 down vote accepted

Any draggable object will fire dragstart, dragend and other drag-related events.

Simply listen to the dragend events of the marker you marked as draggable, and subscribe a handler that gets the latlng value from the sent event:

marker.on('dragend', function(event) {
    var marker =;  // you could also simply access the marker through the closure
    var result = marker.getLatLng();  // but using the passed event is cleaner
share|improve this answer
hi Matti, For some reason its giving me result as undefined... – DomincJune Nov 6 '12 at 11:31
@DomincJune I had been too quick and had forgot to navigate the .target property of event. This should be fixed now. – MattiSG Nov 16 '12 at 21:18
As a newbie, this post has been very useful along with this one on Leaflet Mailing List. – Inan Berbatov Mar 6 '13 at 17:36

Your Answer


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.