Need to know coordinates of manualy draggable marker on map

Showing 1-7 of 7 messages
Need to know coordinates of manualy draggable marker on map gr33tx 9/11/12 1:13 AM
I'm new to javascript and Jquery. Please, help me with advice. I need user can set coordinates manually. I can drag marker but cant get its coordinates. How to get coordinates of marker on "enddrag"? Thanks 
Re: [Leaflet] Need to know coordinates of manualy draggable marker on map Guillaume DUGAS 9/11/12 1:31 AM
marker.on('dragend', function (e) {
 var coords = e.target.latlng;
 var lat = coords.lat;
 var lng = coords.lng;
 // ...
});

2012/9/11 gr33tx <svsv...@gmail.com>
I'm new to javascript and Jquery. Please, help me with advice. I need user can set coordinates manually. I can drag marker but cant get its coordinates. How to get coordinates of marker on "enddrag"? Thanks 

--
 
 
 

Re: [Leaflet] Need to know coordinates of manualy draggable marker on map Guillaume DUGAS 9/11/12 1:33 AM
Sorry for the error, here the answer:

marker.on('dragend', function (e) {
 var coords = e.target.getLatLng();
 var lat = coords.lat;
 var lng = coords.lng;
 // ...
});

2012/9/11 Guillaume DUGAS <dugas.g...@gmail.com>

Re: [Leaflet] Need to know coordinates of manualy draggable marker on map gr33tx 9/11/12 2:10 AM
Thanks a lot DUGAS !

Re: [Leaflet] Need to know coordinates of manualy draggable marker on map gr33tx 9/11/12 2:57 AM

L.marker([54.7067, 20.50967]).addTo(map)
.bindPopup("<b> 1 </b>")
.dragging.enable();
//alert(toString(map.marker.getLatLng()));


marker.on('dragend', function (e) {
var coords = e.target.getLatLng();
var lat = coords.lat;
var lng = coords.lng;
alert (lat);
// ...
});

Sorry, it doesn work. How to connect it with my marker? Probably:

 L.marker.on('dragend', function (e) {

var coords = e.target.getLatLng();
var lat = coords.lat;
var lng = coords.lng;
alert (lat);
// ...
});

??? but its not work too
Re: [Leaflet] Need to know coordinates of manualy draggable marker on map Guillaume DUGAS 9/11/12 3:07 AM
You just need to assign your marker to your "marker" var, like that:

var marker = L.marker([54.7067, 20.50967]).addTo(map)
...
 
and then, you can bind your event:

marker.on('dragend', function (e) {
...

all the basics are explained here: http://leaflet.cloudmade.com/examples/quick-start.html


Good luck !

2012/9/11 gr33tx <svsv...@gmail.com>

--
 
 
 

Re: Need to know coordinates of manualy draggable marker on map gr33tx 9/11/12 5:20 AM

Thanks a lot! It's work!