-
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
Always wrap center coordinate to the range [-180, 180] #11448
Conversation
011f099
to
de066d9
Compare
export function shortestAngle(a: number, b: number): number { | ||
const diff = (b - a + 180) % 360 - 180; | ||
return diff < -180 ? diff + 360 : diff; | ||
} |
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.
Why is this function in util.js
rather than inlined? Will it be used in other places? Or is this for ease of unit testing?
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.
Finding signed distance between two angles is a quite common and useful operation and a good candidate for having its own utility function. I couldn't find any good reasons for inlining it as the code path is not particularly hot and it's easier to test too. Would you like to see it inlined instead?
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.
Those all seem like good reasons. Great work @mpulkki-mapbox!
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.
LGTM! Could you also make sure to update the changelog entry for that change?
Panning the map doesn't automatically wrap the center point to the range [-180, 180]. User can move the map outside of the screen so that nothing gets rendered. This is possible as
center.wrap()
is invoked only during easing of the fling gesture and not at all if user pans the map without leaving any inertia.gljs_center_wrap_bug.mp4
This PR fixes the issue by wrapping the center point in
transform._translateCameraConstrained()
. Additionally thepointCoordinate
implementation for the globe view had to be updated to return non-wrapped coordinates to reflect the change.Fixes the following issue #11354 which was caused by mixed usage of wrapped and unwrapped coordinates in tile coverage computations.
Launch Checklist
mapbox-gl-js
changelog:<changelog>Fix map center not being wrapped properly after a drag gesture.</changelog>