Skip to content

Commit a8d1e39

Browse files
authored
Merge pull request #1852 from mapbox/1ec5-carplay-custom-puck-1734
Allow CarPlayManagerDelegate to customize user location annotation views
2 parents cb4533a + 3828089 commit a8d1e39

File tree

5 files changed

+19
-4
lines changed

5 files changed

+19
-4
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@
99
* Renamed `CarPlayManager(_:)` to `CarPlayManager(styles:directions:eventsManager:)` and `CarPlayNavigationViewController(with:mapTemplate:interfaceController:manager:styles:)` to `CarPlayNavigationViewController(navigationService:mapTemplate:interfaceController:manager:styles:)`. These initializers now accept an array of `Style` objects to apply throughout the CarPlay interface, similar to `NavigationViewController`. You can also change the styles at any time by setting the `CarPlayManager.styles` property. ([#1836](https://github.com/mapbox/mapbox-navigation-ios/pull/1836))
1010
* `CarPlayManager(styles:directions:eventsManager:)` also allows you to pass in a custom `Directions` object to use when calculating routes. ([#1834](https://github.com/mapbox/mapbox-navigation-ios/pull/1834/))
1111
* Removed the `StyleManager(_:)` initializer. After initializing a `StyleManager` object, set the `StyleManager.delegate` property to ensure that the style manager’s settings take effect. ([#1836](https://github.com/mapbox/mapbox-navigation-ios/pull/1836))
12+
* Added `CarPlayManager.mapView` and `CarPlayNavigationViewController.mapView` properties. ([#1852](https://github.com/mapbox/mapbox-navigation-ios/pull/1852))
1213
* Some additional members of `CarPlayManager` are now accessible in Objective-C code. ([#1836](https://github.com/mapbox/mapbox-navigation-ios/pull/1836))
1314
* Fixed an issue where distances are incorrectly displayed as “0 m” in regions that use the metric system. ([#1854](https://github.com/mapbox/mapbox-navigation-ios/pull/1854))
1415
* Fixed an issue where the user puck pointed away from the route line during turn-by-turn navigation in CarPlay. The map’s vanishing point now accounts for safe area insets, including the side maneuver view. ([#1845](https://github.com/mapbox/mapbox-navigation-ios/pull/1845))
16+
* Fixed an issue where the map view used for browsing and previewing failed to call `MGLMapViewDelegate.mapView(_:viewFor:)` and `MGLMapViewDelegate.mapViewWillStartLocatingUser(_:)`. ([#1852](https://github.com/mapbox/mapbox-navigation-ios/pull/1852))
17+
* You can now create a `UserPuckCourseView` using the `UserPuckCourseView(frame:)` initializer. ([#1852](https://github.com/mapbox/mapbox-navigation-ios/pull/1852))
1518

1619
### Other changes
1720

MapboxNavigation/CarPlayManager.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,14 @@ public class CarPlayManager: NSObject {
144144
formatter.allowedUnits = [.day, .hour, .minute]
145145
return formatter
146146
}()
147+
148+
/**
149+
The main map view displayed inside CarPlay.
150+
*/
151+
@objc public var mapView: NavigationMapView? {
152+
let mapViewController = carWindow?.rootViewController as? CarPlayMapViewController
153+
return mapViewController?.mapView
154+
}
147155
}
148156

149157

MapboxNavigation/CarPlayMapViewController.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import CarPlay
55
@available(iOS 12.0, *)
66
class CarPlayMapViewController: UIViewController {
77

8-
static let defaultAltitude: CLLocationDistance = 16000
8+
static let defaultAltitude: CLLocationDistance = 850
99

1010
var styleManager: StyleManager?
1111

@@ -100,7 +100,6 @@ class CarPlayMapViewController: UIViewController {
100100
styleManager!.styles = styles
101101

102102
resetCamera(animated: false, altitude: CarPlayMapViewController.defaultAltitude)
103-
mapView.setUserTrackingMode(.followWithCourse, animated: true)
104103
}
105104

106105
override func viewWillDisappear(_ animated: Bool) {

MapboxNavigation/CarPlayNavigationViewController.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@ public class CarPlayNavigationViewController: UIViewController {
2222
@objc public var drivingSide: DrivingSide = .right
2323

2424
var navService: NavigationService
25-
var mapView: NavigationMapView?
25+
26+
/**
27+
The map view showing the route and the user’s location.
28+
*/
29+
@objc public fileprivate(set) var mapView: NavigationMapView?
30+
2631
let shieldHeight: CGFloat = 16
2732
var mapViewLeftSafeAreaBalancingConstraint: NSLayoutConstraint?
2833
var mapViewRightSafeAreaBalancingConstraint: NSLayoutConstraint?

MapboxNavigation/UserCourseView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public class UserPuckCourseView: UIView, UserCourseView {
8181

8282
var puckView: UserPuckStyleKitView!
8383

84-
override init(frame: CGRect) {
84+
public override init(frame: CGRect) {
8585
super.init(frame: frame)
8686
commonInit()
8787
}

0 commit comments

Comments
 (0)