-
-
Notifications
You must be signed in to change notification settings - Fork 689
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
map.fitBounds has weird animation "jerk" in right conditions #582
Comments
Interesting... Probably an edge condition as can be indicated by the parameters you set. |
Spanning the antimeridian under mapbox/maplibre has been an issue since the beginning. To fix it would require a lot of work, as there are many (wrong) assumptions made on the given coordinates for a bounding box throughout the rendering engine (all revolving around the false basis that the west longitude is always less than the east longitude). Luckily, there is a work-around -- simply go past the max longitude extent whenever you want to span the antimeridian. In your example, change:
to
and it should work as expected. |
Hi j5kay, thanks for the response. I guess my sample code pen was not clear. I do want the map to end up over centered over africa as my data is spread out world wide (although the trick for spanning the antimeridian is going in the toolbox for later!). Its the animation with the jerk that I am hoping to avoid. I've updated my codepen above with a point at 0,0 to show that is where i want to be centered without the animation jerk. |
This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 30 days. |
Is this related to #1299? |
Was this fixed? Can you check latest versions? |
So I checked the demo I made for this here: Link to Demonstration Which is using latest: ``` <script src="https://unpkg.com/maplibre-gl@latest/dist/maplibre-gl.js"></script>```And it still occurs. |
When the map is the right dimensions (i.e. thinner than it is tall) and the map.fitBounds method is called for a approximate world wide zoom event (eg: map.fitBounds([-179, -89, 179, 89]); ), the zoom animation seems to animate with the left edge of the map lined up with the left edge of the element and then when animation is complete, jump to place the centre of the bounds in the middle of the map.
maplibre-gl-js version: 1.14.*, 1.15
browser: Chrome and Edge
Steps to Trigger Behavior
map.fitBounds([-179, -89, 179, 89]);
Link to Demonstration
https://codepen.io/Terribill/pen/qBmxyqR
Expected Behavior
I expect the map to animate with the centre of the bounding box in the centre of the visible map area.
Actual Behavior
The map animates showing the left most area of the bounds, then when animation is complete, jumps to show centre of the bounding area.
The text was updated successfully, but these errors were encountered: