-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Zoom to bounding box (fitBounds) zooming in too far with non-Mercator projections #11284
Comments
On further testing, this issue should be renamed to "Zoom bounding box (fitBounds) zooming incorrectly with non-Mercator projections. When using 'albers' for the projection, the fitBounds does not zoom far enough in and shows much more than the bounding box. You can use the demo link above to test and just change the projection to "albers". Similarly, when a user performs an interactive zoom (shift + draw box on desktop) the zoom function does not work as expected. |
Possibly related bug: When the map is pitched with a non mercator projection, the shift+bbox zoom behaves quite erratically
|
We've encountered this issue as well in some of our work. What's the primary cause of this bug? Is there a pathway to solving it? |
I had the same problem. I solved adding a center on the fitbounds method.
|
I could not get adding a center to work properly. Still over-zoomed past the bounds when not using mercator. I then did a test like this...and it kind of works, but with some amusing visual results (especially if you exaggerate the duration):
|
@stonetip for whatever reason, adding center did work me, using albers- |
@stonetip Oh, I noticed fitBounds does weird things if you're trying to change projection at the same time. I would put the setProjection call in a timeout so that it execute once fitBounds is done (5000ms in your example). Or alternatively, change the projection before calling fitBounds- |
This is still happening with the globe projection. Adding the center to the options doesn't work. Is this going to be fixed any time soon? |
with globe projection, |
Hey everyone, We've improved the |
It looks like it's already working on v3.4.0 with the globe projection. I'm sorry, I should have mentioned the version I used in my previous comment. It was only 3.0.1. |
mapbox-gl-js version: 2.6.0
browser: Chrome
Steps to Trigger Behavior
Mercator (expected behavior):
Natural Earth projection:
Equal Earth projection:
Link to Demonstration
Made using the 'Fly To' GL JS demo: https://jsbin.com/huhataxilu/edit?html,output
Also two counties that demonstrate this issue quite clearly, reported to me:
Expected Behavior
Zoom to display the full bounding box (not cut off any area within the bounding box)
Actual Behavior
Zooms slightly too far in, cutting off part of the bounding box area.
Workaround solution is to increase the padding as a 'buffer' around the bounding box.
The text was updated successfully, but these errors were encountered: