-
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
When fitBounds() is called with nonzero bearing, rotate padding #9821
Conversation
@arindam1993 please take a look at this when you have a chance. thanks! |
@allison-strandberg thanks so much for the detailed PR (and for your patience)! This looks great to me and seems to work well in the linked example.
@arindam1993 can you confirm this?
No, this shouldn't affect performance much.
Yes, you added the changelog entry already. We also add a label such as "feature" or "bug" but I'll do that now. |
@arindam1993 do you have a timeline on reviewing this? thanks! |
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.
Thanks for the PR @allison-strandberg , could you please describe in more detail why you think the offset should be rotated in more detail?
@arindam1993 I've submitted a change so that the offset is no longer rotated: does this look good to you? |
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.
Sorry for the delay in looking at this, thanks this looks good to me now. 🙇 Thanks for working on this
Has this been resolved? |
Fixes #9641
This is my first PR here—let me know if I'm missing anything!
This PR changes the behavior of
fitBounds()
. Previously, whenfitBounds()
was called with asymmetrical padding and a nonzero bearing, the padding was applied without considering the map's rotation. For example, if the bearing was 90 degrees, a left padding value would be applied to the bottom of the map. Now, left padding is applied to the left side of the map regardless of the direction of north.There are two main changes:
cameraForBounds()
. Previously, the bearing passed to_cameraForBoxAndBearing()
from this function was hardcoded as 0. This was the subject of PR Allow passing bearing as an option ot fitBounds #7618, which was not merged: I copied tests from that PR._cameraForBoxAndBearing()
, rotate both the offset and padding values by the bearing.The following JSFiddles demonstrate the change. The "Fit to Kenya" button calls fitBounds with a bearing of 90 degrees and a left padding of 200 pixels.
Using v1.11.0: Padding is on the bottom.
Using this fork: Padding is on the left.
Questions
_cameraForBoxAndBearing()
, the offset and padding are rotated, added together, then scaled by the zoom. Is this order correct?Launch Checklist
mapbox-gl-js
changelog:<changelog>When fitBounds() is called with nonzero bearing, rotate padding</changelog>