0

How to get the latlng after the dragend event in leaflet

var osmUrl = 'http://{s}.tile.osm.org/{z}/{x}/{y}.png',
    osmAttrib = '&copy; <a href="http://openstreetmap.org/copyright">OpenStreetMap</a> contributors',
    osm = L.tileLayer(osmUrl, {
        maxZoom: 18,
        attribution: osmAttrib
    });
var map = L.map('map').setView([19.04469, 72.9258], 12).addLayer(osm);

function onMapClick(e) {
    var marker = L.marker(e.latlng, {
            draggable: true,
            title: "Resource location",
            alt: "Resource Location",
            riseOnHover: true
        }).addTo(map)
        .bindPopup(e.latlng.toString()).openPopup();
    marker.on("dragend", function(ev) {
        var chagedPos = ev.target.getLatLng();
        this.bindPopup(chagedPos.toString()).openPopup();
    });
}
map.on('click', onMapClick);
<div id="map"></div>  
#map {
   height: 480px;
   width: 100%;
}
RUN
add comment
Suggest a different solution or add another example