mapbox / mapbox/mapbox-maps-android
Mapbox 11 breaks cameraForCoordinates
Nobody has claimed this yet.
- Dominant language
- Kotlin
- Stars
- 578
- Forks
- 161
- PR merge metrics
- No merged PRs in 30d
Description
## Environment
- Android OS version: 13
- Devices affected: Samsung Tab Active4 Pro
- Maps SDK Version: 11.0.0, 11.1.0, 11.2.0-beta.1, 11.2.0
## Observed behavior and steps to reproduce
`cameraForCoordinates` gives zoom levels that are too zoomed out outside of 45 degree rotation increments.
We underlay a mapbox map to fit coordinates given the lat lon of the topLeft and bottomRight of the screen.
```
map.setCamera(
map.cameraForCoordinates(
listOf(fromLngLat(topLeft.x, topLeft.y), fromLngLat(bottomRight.x, bottomRight.y)),
EdgeInsets(0.0, 0.0, 0.0, 0.0),
Math.toDegrees(renderer.rotation),
0.0
)
)
```
This only works when the rotation in degrees % 45 == 0. Outside of this the returned zoom from `cameraForCoordinates` is too zoomed out.
https://github.com/mapbox/mapbox-maps-android/assets/7464462/2068a31d-946c-499e-b3b5-a3968ed36c37
## Expected behavior
The yellow always aligns with the map (as it does at 45 degree rotation increments).
This is what happens in Mapbox 10.
## Notes / preliminary analysis
Must be somehow fitting a rectangle of the wrong rotation in somewhere to get this effect.
The returned centre is fine, only the zoom returned by `cameraForCoordinates` is wrong.
Add tests outside 45 degree increments.
## Additional links and references
Regression from Mapbox 10 (code is the same, broken after updating to 11).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the cameraForCoordinates implementation and its existing tests in the Mapbox Maps SDK Android codebase. Reproduce the issue using rotations outside 45-degree increments and compare the returned zoom with Mapbox 10 behavior. Add coverage for those rotations and consider the issue done when the calculated camera keeps the coordinates aligned without excessive zoom-out.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, kotlin
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100