The base template for your CarPlay navigation app will always be a map template.


class CPMapTemplate : CPTemplate


The Map Template is a control layer that appears as an overlay over the base view and allows you to present user controls.

The control layer consists of a navigation bar and map buttons. By default, the navigation bar appears when the user interacts with the app, and disappears after a period of inactivity.

The navigation bar includes up to two leading buttons and two trailing buttons. You can customize the appearance of these buttons with icons or text.

The control layer may also include up to four map buttons. The map buttons are always shown as icons.

Navigation apps enter panning mode, zoom in or out, and perform other functions by responding to user actions on these buttons.

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

class CPNavigationAlert

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

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.

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

CarPlay Navigation App UI Elements

class CPListTemplate

A hierarchical list of menu items can be displayed on the CarPlay screen using a list template.

class CPGridTemplate

A grid of menu items can be displayed on the CarPlay screen using a grid template.

class CPSearchTemplate

The search results for a given destination can be displayed on the CarPlay screen using a search template.