Bugfix: _cameraForBoxAndBearing not fitting bounds properly when using asymettrical camera viewport and bearing #3591
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I work with rotated maps a lot and noticed that fitting to bounds was not functioning as expected for some cases. In digging into this came to realize that the NW-SE points on the bounding box were always being fit to even in cases when fitting to these points leads to the NE-SW points being out of frame.
The code was updated to consider all corners of the bounding box when rotating and fitting.
In performing the update it highlighted two existing test cases which were incorrect and so these were updated as well. A new test case was added which is similar to the case presented in the JS Fiddle.
I also added a small
degreesToRadians
utility function since it felt cleaner to use this than repeatedly typingdegrees * Math.PI / 180
JS Fiddle with a demo of the bug: https://jsfiddle.net/z4xma2wk/3/
Actual result when fitting bounds with 45deg rotation:
Approx. expected result when fitting bounds with 45deg rotation:
Launch Checklist