Skip to content

Commit

Permalink
Position puck in lower portion of screen. (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelkirk authored Aug 14, 2024
1 parent 446aecc commit b8bdcfd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
- Merged in <https://github.com/maplibre/maplibre-navigation-ios/pull/47>
* Fix: NavigationViewController displayed incorrect `speedMultiplier` when using SimulatedLocationManager
- Merged in <https://github.com/maplibre/maplibre-navigation-ios/pull/49>
* Adjusted the camera during navigation to show more of what's "ahead" in the route - effectively moving the puck lower on the screen. As before, see `NavigationMapViewCourseTrackingDelegate.updateCamera(_:location:,routeProgress:)` if you want to customize this behavior.
- Merged in <https://github.com/maplibre/maplibre-navigation-ios/pull/92>

## v2.0.0 (May 23, 2023)
* Upgrade minimum iOS version from 11.0 to 12.0.
Expand Down
7 changes: 6 additions & 1 deletion MapboxNavigation/NavigationMapView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,12 @@ open class NavigationMapView: MLNMapView, UIGestureRecognizerDelegate {
if !cameraUpdated {
let newCamera = MLNMapCamera(lookingAtCenter: location.coordinate, acrossDistance: self.altitude, pitch: 45, heading: location.course)
let function = CAMediaTimingFunction(name: CAMediaTimingFunctionName.linear)
setCamera(newCamera, withDuration: 1, animationTimingFunction: function, edgePadding: UIEdgeInsets.zero, completionHandler: nil)

// Because it's more useful to show what's ahead than what's behind, we bias the camera to put
// the user location puck in the lower portion of the visible map, showing more of what's ahead.
let edgePadding = UIEdgeInsets(top: bounds.height * 0.4 - safeAreaInsets.bottom, left: 0, bottom: 0, right: 0)

setCamera(newCamera, withDuration: 1, animationTimingFunction: function, edgePadding: edgePadding, completionHandler: nil)
}
}

Expand Down

0 comments on commit b8bdcfd

Please sign in to comment.