Skip to content

Commit 5bb326c

Browse files
authored
Fix unexpected camera jumps when showing the list of upcoming maneuvers (#4400)
* Fix camera jumps when showing the list of upcoming maneuvers
1 parent f6cf288 commit 5bb326c

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
**Note:** The Mapbox Electronic Horizon feature of the Mapbox Navigation SDK is in public beta and is subject to changes, including its pricing. Use of the feature is subject to the beta product restrictions in the Mapbox Terms of Service. Mapbox reserves the right to eliminate any free tier or free evaluation offers at any time and require customers to place an order to purchase the Mapbox Electronic Horizon feature, regardless of the level of use of the feature.
1414
* Added`Interchange.identifier` and `Junction.identifier` fields. ([#4396](https://github.com/mapbox/mapbox-navigation-ios/pull/4396))
1515

16+
### Camera
17+
18+
* Fixes an issue where the camera's position was not calculated correctly when banners fully overlapped the map. ([#4400](https://github.com/mapbox/mapbox-navigation-ios/pull/4400))
19+
1620
## v2.11.0
1721

1822
### Packaging

Sources/MapboxNavigation/CameraController.swift

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,17 @@ class CameraController: NavigationComponent, NavigationComponentDelegate {
130130

131131
private func updateNavigationCameraViewport() {
132132
if let navigationViewportDataSource = navigationMapView.navigationCamera.viewportDataSource as? NavigationViewportDataSource {
133-
navigationViewportDataSource.viewportPadding = viewportPadding
133+
let newViewport = viewportPadding
134+
let visibleRect = navigationMapView.mapView.bounds.inset(by: newViewport)
135+
136+
guard visibleRect.size.width > 0, visibleRect.size.height > 0 else {
137+
// The viewport padding is bigger than the map itself,
138+
// this usually means that it is being fully overlapped by one of the banners
139+
// In this case, we ignore new viewport to avoid unexpected camera jumps
140+
return
141+
}
142+
143+
navigationViewportDataSource.viewportPadding = newViewport
134144
}
135145
}
136146

0 commit comments

Comments
 (0)