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

Misplaced popup when panning the map #3036

Closed
WiS3 opened this issue Aug 19, 2016 · 3 comments
Closed

Misplaced popup when panning the map #3036

WiS3 opened this issue Aug 19, 2016 · 3 comments

Comments

@WiS3
Copy link

WiS3 commented Aug 19, 2016

I have some On click popups attached to geojson points.
I followed the documentation and the implementation is the same, and it's working fine..
But there is an issue:

When i zoom out the map at around 0 i can see the whole earth, if i pan the map i can see the same points at the same Earth coordinates. But the popup does not show up on the clicked point, it show up on the point in the other side (the first one rendered).

I hope you understand the issue, english is not my native and couldn't explain better.

Steps to Trigger Behavior

  1. Put a on-click Popup on a geojson point
  2. Pan the map to the left or right till you see the same point
  3. Click that point

Expected Behavior

The popup should be positioned on the clicked point

Actual Behavior

The popup doesn't appear on the clicked point, but in the point on the other side.

@lucaswoj
Copy link
Contributor

lucaswoj commented Aug 19, 2016

By default, Markers and Popups do not wrap to wrapped "copies" of the world. You will need to do this manually by adding 360 to your popup's latitude.

We have proposed but not implemented a more automatic solution in #2071

@WiS3
Copy link
Author

WiS3 commented Aug 19, 2016

I cannot find any solution on the issue you linked.
I found another workaround to update the map center if the center is ina world copy.. but still does not beehave well with popups.. because you can see at the same time the original world and the copy next to it, and clicking on a popup that is on the world copy part, still show the popup in the wrong position.

Also i've found that this issue applies also to events.. in my case i need to get the coordinates on the click event, and by clicking on a world copy the event return values out of the lat/lng range.

So the only workaround for me is to set maxBounds on the map to prevent panning on world copies.

@elcontraption
Copy link

elcontraption commented Aug 30, 2016

@WiS3 as a workaround, you could offset your popup like so (assuming a scenario where you're clicking on a marker to show a popup in the same place):

const offset = Math.round((event.lngLat.lng - feature.geometry.coordinates[0]) / 360) * 360

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

3 participants