Repository navigation
fix(android): fit camera to zero-height bounds - #4352
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 camera-fitting bounds symmetrically by one millionth of a degree. - Preserve exact camera constraints and nonzero-height bounds. - Add regression coverage for the midpoint, unchanged bounds, and latitude limits.
RobJacobson
marked this pull request as ready for review
October 13, 2026 03:17
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
Addresses the Android zero-height bounds case in #4050.
When both bounds corners share a latitude, Mapbox's camera-fitting method returns zoom 0 even when the longitude span is nonzero.
CameraStopnow expands fitting bounds by 0.000001 degrees north and south before calling the SDK. This preserves the bounds' midpoint and longitudes while giving the fitter a nonzero latitude span.The expansion applies only to camera fitting.
toBounds()continues to return exact bounds for camera constraints, and nonzero-height fitting bounds remain unchanged. This PR adds three regression tests covering the midpoint, exact constraints, vertical/thin bounds, and valid latitude limits.Checklist
CONTRIBUTING.mdand.github/REPRODUCING.mdyarn generatein the root folder (no generated differences)/exampleapp./example) — not applicable; this is a bug fix. The standalone reproducer is included below and is not committed.Before/after verification
The same standalone component was run in rebuilt unfixed and fixed Android example apps with Mapbox 11.23.1, React Native 0.84.1, and New Architecture enabled, on an Android 17 arm64 emulator with 16 KB pages. The map measured 411.4 × 811.4 React Native screen points.
The check requires both original coordinates to lie within the viewport and their horizontal span to be within 3 points of the map width. This rejects the world-scale view even though both points technically remain on screen. The native fitter returns zoom 0 before the workaround; the SDK constrains the applied camera to 0.664 in this example.
Earlier native-only verification also compared the actual bounds helper against unmodified bounds on Mapbox 11.15.3 and 11.23.1. Both versions returned 0 before expansion and 8.326850767922837 after expansion for the original horizontal coordinates. Eleven native scenarios passed per version, including southern/equatorial/northern latitudes, single-point and tiny bounds, vertical/diagonal bounds, bearing 45 degrees, and pitch 30 degrees. Nonzero-height cases produced identical camera options before and after the helper.
Additional checks:
yarn test: lint passed; 25 suites and 164 JavaScript unit tests passed.LatLngBoundsTest: 3 tests passed; the changed Android library and example app compiled successfully.yarn generate: completed without generated changes.git diff --check: passed.Captured example-app results
Component to reproduce the issue you're fixing
Replace
example/src/examples/BugReportExample.jswith the component below and open the Bug Report Template example. It uses a local blank style and a dummy access token, with no external data or additional libraries. It automatically fits once the style loads; the button repeats the same fit. A failing build displaysFAIL, and the fixed build displaysPASS.BugReportExample.js