2

I have to do a draggable marker and its coordinates should be displayed in fields. It will be a part of a contact form in PHP. I created a draggable marker, help me what to do now.

var marker = L.marker(new L.LatLng(53.471, 18.744), {
draggable: true
}).addTo(map);

http://jsfiddle.net/xTh5U/

Here is example in Google Maps API, I need the same in Leaflet.

2

Use dragend method for the marker. Look through the jsfiddle.I hope it helps. http://jsfiddle.net/Poshan/w6ej59jk/5/

  • You solved half of my problem - how to receive cooordinates from dragged marker. Now I need to do the second part of Google Maps API example - how to display the coordinates in field form. – Helios Dec 3 '14 at 11:21
  • That's what addToTextBox() accomplishes. Just add add the ids lat and lng to two elements in your form, or combine them using something like [lt, ln].join(', ') – James Conkling Dec 5 '14 at 21:58

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.