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

[Bug] fitBounds not working as expected in my app and in the react-map-gl example #2437

Open
DaveSeidman opened this issue Oct 21, 2024 · 0 comments
Labels

Comments

@DaveSeidman
Copy link

Description

First off, thank you for this wonderful library, it's powerful, performant, and easy to use. I'm currently experiencing some inconsistent behavior with the fitBounds method. I've observed the issue in my own code as well as the react-map-gl hosted example here: https://visgl.github.io/react-map-gl/examples/zoom-to-bounds

If you watch the attached screen recording you'll notice the final position and zoom is different depending on the current view and where in the interactiveLayer the click happened. It always works correctly if you zoom the map out sufficiently before clicking a region.

Screen.Recording.2024-10-21.at.7.28.30.AM.mp4

I've worked around the issue by using the polygon from the original geoJson I'm loading to set the bounding box but it would be nice not to have to do that additional lookup as I believe the correct data should exist inside the onMapClick event's data.

Expected Behavior

I'd expect the MapLayerMouseEvent.features to be the same every time when clicking into the same interactive layer.

Steps to Reproduce

Pull this repo, and run the "zoom-to-bounds" example, add a line inside the onMapClick event to console the event.features[0].geometry.coordinates[0].flat() and observe different values returned when clicking at different points within the same feature.

Environment

Logs

No response

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

No branches or pull requests

1 participant