CarPlayNavigationViewController
@available(iOS 12.0, *)
public class CarPlayNavigationViewController : UIViewController, NavigationMapViewDelegate
extension CarPlayNavigationViewController: StyleManagerDelegate
CarPlayNavigationViewController
is a fully-featured turn-by-turn navigation UI for CarPlay.
Seealso
NavigationViewController-
The view controller’s delegate.
Declaration
Swift
public weak var carPlayNavigationDelegate: CarPlayNavigationDelegate? { get set }
-
Provides all routing logic for the user.
See
NavigationService
for more information.Declaration
Swift
public var navigationService: NavigationService
-
The map view showing the route and the user’s location.
Declaration
Swift
public fileprivate(set) var mapView: NavigationMapView? { get }
-
A view indicating what direction the vehicle is traveling towards, snapped to eight cardinal directions in steps of 45°.
This view is hidden by default.
Declaration
Swift
weak public var compassView: CarPlayCompassView!
-
A view that displays the current speed limit.
Declaration
Swift
public weak var speedLimitView: SpeedLimitView!
-
The interface styles available for display.
These are the styles available to the view controller’s internal
StyleManager
object. In CarPlay,Style
objects primarily affect the appearance of the map, not guidance-related overlay views.Declaration
Swift
public var styles: [Style] { get set }
-
Controls whether the main route style layer and its casing disappears as the user location puck travels over it. Defaults to
false
.If
true
, the part of the route that has been traversed will be rendered with full transparency, to give the illusion of a disappearing route. To customize the color that appears on the traversed section of a route, override thetraversedRouteColor
property for theNavigationMapView.appearance()
.Declaration
Swift
public var routeLineTracksTraversal: Bool { get set }
-
Creates a new CarPlay navigation view controller for the given route controller and user interface.
Postcondition
Call
startNavigationSession(for:)
after initializing this object to begin navigation.Declaration
Swift
required public init(navigationService: NavigationService, mapTemplate: CPMapTemplate, interfaceController: CPInterfaceController, manager: CarPlayManager, styles: [Style]? = nil)
Parameters
navigationService
The navigation service managing location updates for the navigation session.
mapTemplate
The map template visible during the navigation session.
interfaceController
The interface controller for CarPlay.
manager
The manager for CarPlay.
styles
The interface styles that the view controller’s internal
StyleManager
object can select from for display. -
Begins a navigation session along the given trip.
Declaration
Swift
public func startNavigationSession(for trip: CPTrip)
Parameters
trip
The trip to begin navigating along.
-
Ends the current navigation session.
Declaration
Swift
public func exitNavigation(byCanceling canceled: Bool = false)
Parameters
canceled
A Boolean value indicating whether this method is being called because the user intends to cancel the trip, as opposed to letting it run to completion.
-
Shows the interface for providing feedback about the route.
Declaration
Swift
public func showFeedback()
-
A Boolean value indicating whether the map should follow the user’s location and rotate when the course changes.
When this property is true, the map follows the user’s location and rotates when their course changes. Otherwise, the map shows an overview of the route.
Declaration
Swift
@objc public dynamic var tracksUserCourse: Bool { get set }
-
Declaration
Swift
public func location(for styleManager: StyleManager) -> CLLocation?
-
Declaration
Swift
public func styleManager(_ styleManager: StyleManager, didApply style: Style)
-
Declaration
Swift
public func styleManagerDidRefreshAppearance(_ styleManager: StyleManager)