Leaflet.Editable icon indicating copy to clipboard operation
Leaflet.Editable copied to clipboard

get marker coordinate

Open meteerogl opened this issue 5 years ago • 4 comments

I want to collect line point (markers) coordinates. how can ı do.

meteerogl avatar Mar 31 '19 13:03 meteerogl

~~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())
      }
    })

kajeagentspi avatar Mar 31 '19 13:03 kajeagentspi

thamks this solution worked

meteerogl avatar Apr 01 '19 10:04 meteerogl

also ı have another question. İf change marker position. the data doesnt be change. how can get live marker position data....

meteerogl avatar Apr 01 '19 12:04 meteerogl

Try changing editable:drawing:end to other events from this page. http://leaflet.github.io/Leaflet.Editable/doc/api.html

kajeagentspi avatar Apr 01 '19 15:04 kajeagentspi