Control the CarPlay display using a map template.


class CPMapTemplate : CPTemplate


Use the map template to:

  • Present controls that appear directly on the map, including the navigation bar and map buttons.

  • Present navigation alerts.

  • Manage the map's panning interface.

When the system calls application(_:didConnectCarInterfaceController:to:)—implemented in your app delegate—create a CPMapTemplate object, then set the root template on the interface controller by calling setRootTemplate(_:animated:).


Handling Map Template Events

var mapDelegate: CPMapTemplateDelegate?

The object that serves as the delegate of the map template.

protocol CPMapTemplateDelegate

The protocol you implement to handle events from a map template.

Managing Map Buttons

var mapButtons: [CPMapButton]

An array of map buttons displayed on the trailing bottom corner of the map template.

class CPMapButton

A button representing an action that a map template displays on the CarPlay screen.

Displaying Trip Previews

func hideTripPreviews()

Hides the display of trip previews.

Navigating a Trip

var automaticallyHidesNavigationBar: Bool

A Boolean value that indicates whether the navigation bar hides automatically.

var hidesButtonsWithNavigationBar: Bool

A Boolean value that tells the system to hide the map buttons when hiding the navigation bar.

func updateEstimates(CPTravelEstimates, for: CPTrip)

Updates the travel estimates—such as arrival time, and time and distance remaining—for a trip.

Displaying a Navigation Alert

func present(navigationAlert: CPNavigationAlert, animated: Bool)

Displays a navigation alert on the map template.

func dismissNavigationAlert(animated: Bool, completion: (Bool) -> Void)

Tells the map template to dismiss the visable navigation alert.

class CPNavigationAlert

An alert panel that displays (map- or navigation-related) information to the user.

Displaying the Panning Interface

func showPanningInterface(animated: Bool)

Shows the panning interface over the map.

func dismissPanningInterface(animated: Bool)

Dismisses the panning interface.


Inherits From

See Also

First Steps

protocol CPApplicationDelegate

The interface for handling CarPlay life cycle events.