Skip to content

Returned feature coordinates different then original feature? #609

Answered by astridx
bdullemond asked this question in Q&A
Discussion options

You must be logged in to vote

I also think that the output in your popup is correct. If I read the documentation and the code for map.on('mouseenter', 'places',..) correctly, then the coordinate of the mouse position on the places layer is displayed as accurately as possible.

The source, I mean the value for e.features[0].geometry.coordinates of the GeoJson is not the target of the event. I think that is what you expect. But you would have to do this differently.

In your case, however, I think that the easiest thing to do is to use:

popup.setLngLat(coordinates).setHTML(description + coordinates[0].toFixed(2) + "," + coordinates[1].toFixed(2)).addTo(map);

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by bdullemond
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants