CarPlayNavigationViewController
@available(iOS 12.0, *)
open class CarPlayNavigationViewController : UIViewController, BuildingHighlighting
extension CarPlayNavigationViewController: StyleManagerDelegate
extension CarPlayNavigationViewController: NavigationServiceDelegate
extension CarPlayNavigationViewController: NavigationMapViewDelegate
extension CarPlayNavigationViewController: CPSessionConfigurationDelegate
CarPlayNavigationViewController
is a fully-featured turn-by-turn navigation UI for CarPlay.
Seealso
NavigationViewController
-
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
public var compassView: CarPlayCompassView!
-
A view that displays the current speed limit.
Declaration
Swift
public var speedLimitView: SpeedLimitView!
-
A view that displays the current road name.
Declaration
Swift
public var wayNameView: WayNameView!
-
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 }
-
Toggles displaying alternative routes.
If enabled, view will draw actual alternative route lines on the map. Default value is
true
.Declaration
Swift
public var showsContinuousAlternatives: Bool { get set }
-
AlternativeRoute
s user might take during this trip to reach the destination using another road.Array contents are updated automatically duting the trip. Alternative routes may be slower or longer then the main route. To get updates, subscribe to
Notification.Name.routeControllerDidUpdateAlternatives
notification.Declaration
Swift
public var continuousAlternatives: [AlternativeRoute] { get }
-
Controls whether night style will be used whenever traversing through a tunnel. Defaults to
true
.Declaration
Swift
public var usesNightStyleWhileInTunnel: Bool
-
Controls the styling of CarPlayNavigationViewController and its components.
The style can be modified programmatically by using
StyleManager.applyStyle(type:)
.Declaration
Swift
public private(set) var styleManager: StyleManager? { get }
-
Allows to control highlighting of the destination building on arrival. By default destination buildings will not be highlighted.
Declaration
Swift
public var waypointStyle: WaypointStyle
-
Provides methods for creating and sending user feedback.
Declaration
Swift
public var eventsManager: NavigationEventsManager { get }
-
Shows the interface for providing feedback about the route.
Declaration
Swift
public func showFeedback()
-
The view controller’s delegate, that is used by the
CarPlayManager
.Do not overwrite this property and use
CarPlayManagerDelegate
methods directly.Declaration
Swift
public weak var delegate: CarPlayNavigationViewControllerDelegate?
-
CarPlayManager
instance, which contains mainUIWindow
content and is used byCarPlayNavigationViewController
for presentation.Declaration
Swift
public var carPlayManager: CarPlayManager
-
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 navigationMapView: NavigationMapView? { get }
-
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.
-
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
public required 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.
-
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)
-
Declaration
Swift
public func navigationService(_ service: NavigationService, didArriveAt waypoint: Waypoint) -> Bool
-
Declaration
Swift
public func navigationMapView(_ navigationMapView: NavigationMapView, didAdd finalDestinationAnnotation: PointAnnotation, pointAnnotationManager: PointAnnotationManager)
-
Declaration
Swift
public func navigationMapView(_ navigationMapView: NavigationMapView, routeLineLayerWithIdentifier identifier: String, sourceIdentifier: String) -> LineLayer?
-
Declaration
Swift
public func navigationMapView(_ navigationMapView: NavigationMapView, routeCasingLineLayerWithIdentifier identifier: String, sourceIdentifier: String) -> LineLayer?