Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get marker coordinate #186

Open
meteerogl opened this issue Mar 31, 2019 · 4 comments
Open

get marker coordinate #186

meteerogl opened this issue Mar 31, 2019 · 4 comments

Comments

@meteerogl
Copy link

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

@kajeagentspi
Copy link

kajeagentspi commented Mar 31, 2019

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

@meteerogl
Copy link
Author

thamks this solution worked

@meteerogl
Copy link
Author

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

@kajeagentspi
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants