Leaflet.Editable
Leaflet.Editable copied to clipboard
get marker coordinate
I want to collect line point (markers) coordinates. how can ı do.
~~If you are just using the map to add markers only you can do this.~~
~~this.mapInstance.on('editable:drawing:end', (event) => {~~ ~~console.log(event.layer.getLatLng())~~ ~~})
~~
~~However if you are using the map to draw Polylines or other shapes. You'll get an error using that. I am still looking for a way to get the layer type.~~
This should do the trick
this.mapInstance.on('editable:drawing:end', ({ layer }) => {
if (layer instanceof L.Marker) {
console.log(layer.getLatLng())
} else if (layer instanceof L.Polyline) {
console.log(layer.getLatLngs())
}
})
thamks this solution worked
also ı have another question. İf change marker position. the data doesnt be change. how can get live marker position data....
Try changing editable:drawing:end to other events from this page. http://leaflet.github.io/Leaflet.Editable/doc/api.html