Hi there i am using below code to populate the markers and i used a function to achieve the dragging of the marker and on dragend i am getting the lat,lng of new location......
for (var key in data) {
if ((data[key]["latitude"] != null) & (data[key]["longitude"] != null)){
//populating the markers
if (data.hasOwnProperty(key) ) {
m = L.marker([data[key]["latitude"], data[key]["longitude"]], {
icon: compIcon,title:"Click and Hold Marker to drag",draggble:true
}).bindPopup(data[key]["name"]).addTo(comp_markers);
m.on('dragend', function(e) {
console.log("name of the marker :"+data[key]["name"]);
console.log("please show me changed lat & lon:"+this.getLatLng());
});
}
}
}
My Question is : How to get the name of marker that I dragged but below line gives me name of last marker in the array........
console.log("name of the marker :"+data[key]["name"]);
I tried this keyword expecting it will point to exact marker that user dragging....
console.log("name of the marker :"+this.data[key]["name"]);
I just started learning programming.... Please let me know how ot handle such kind of sutiations........ Thank You