Repository navigation
fix(android): fit zero-height camera bounds - #4353
Closed
RobJacobson wants to merge 1 commit into
Closed
RobJacobson wants to merge 1 commit into
RobJacobson wants to merge 1 commit into
Conversation
- Expand zero-height bounds only for camera fitting to avoid zoom zero. - Preserve viewport padding, bearing, and pitch during bounds fitting. - Add regression tests for degenerate bounds and resolved padding.
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Fixes #4050
Problem and root cause
Camera.setCamera({ bounds })receives the two points from the issue at latitude37. Android converts them into aCoordinateBoundswith a nonzero longitude span and zero latitude span. That degenerate rectangle is passed to Mapbox's camera fitter, which returns a center but a zoom of0. The map therefore falls back to a world view and the points do not fit the viewport. The issue's recording shows the failure; the reporter also observed that bounds with a nonzero latitude span fit correctly.What changes
For camera fitting only, expand a zero-height rectangle symmetrically by
0.000001degrees of latitude, clamped to valid latitude values. This gives the fitter a nonzero height without shifting the center or changing the longitude span. Non-degenerate bounds are passed through unchanged, and the original bounds remain unchanged for camera constraints.The Android bounds path fits the resulting southwest/northeast points with
cameraForCoordinates. It passes the resolved camera padding, bearing, and pitch throughCameraOptions, with zero additionalcoordinatesPaddingso padding is applied once.Regression tests cover equal-latitude bounds, preservation of the center and original bounds, unchanged nonzero spans, latitude limits, and camera padding/bearing/pitch. The Android unit suite passes 15 tests across 5 suites. The Android example app was built and run with Mapbox Maps SDK v11 and the New Architecture; the issue coordinates fit around the Bay Area at a regional zoom instead of showing the world.
Checklist
CONTRIBUTING.mdyarn generate/exampleapp./example)Screenshot OR Video
The issue report includes the original failing screen recording. In the post-fix Android emulator run, Camera > Fit displayed the equal-latitude coordinates fitted around the Bay Area at a regional zoom.
Component to reproduce the issue you're fixing