-
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
Fix flyTo when the final zoom value is not the requested one (#7222) #7223
Conversation
This complete the fix for #6828 when the final zoom value is different from the zoom requested.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of adjusting the scale, could we do the k === 1
condition later in newCenter
, setting it to center
? That way we would make sure the center is exactly the one as passed at the end of the animation.
Also, let's add a unit test that fails without the fix and passes with it to demonstrate that the change is necessary.
src/ui/camera.js
Outdated
const scale = 1 / w(s); | ||
tr.zoom = k === 1 ? zoom : startZoom + tr.scaleZoom(scale); | ||
const scale = k === 1 ? tr.zoomScale(zoom - startZoom) : 1 / w(s); | ||
tr.zoom = startZoom + tr.scaleZoom(scale); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's keep the old k === 1
condition here because zoomScale+scaleZoom may introduce loss of floating point precision.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I will update the PR with your recommendation.
I found example code in the tests to simulate the animation for flyTo, as I think the problem I saw requires the computation of a fly path over several points. I will give it a try. |
…7222) (mapbox#7223) * Fix flyTo when final zoom is not requested one (mapbox#7222) This complete the fix for mapbox#6828 when the final zoom value is different from the zoom requested. * Fix final center position and add test case.
…7222) (mapbox#7223) * Fix flyTo when final zoom is not requested one (mapbox#7222) This complete the fix for mapbox#6828 when the final zoom value is different from the zoom requested. * Fix final center position and add test case.
…7222) (mapbox#7223) * Fix flyTo when final zoom is not requested one (mapbox#7222) This complete the fix for mapbox#6828 when the final zoom value is different from the zoom requested. * Fix final center position and add test case.
This complete the fix for #6828 when the final zoom value is different from the requested zoom.