Contents

CPMapTemplate

A template that displays a navigation overlay that your app draws on the map.

Declaration

@MainActor class CPMapTemplate

Overview

After CarPlay calls your scene delegate’s templateApplicationScene(_:didConnect:to:) method, create a map template and set it as the root template by calling setRootTemplate(_:animated:completion:) on the interface controller the method provides.

The map template appears as an overlay on top of the base view. The template is the control layer, providing a navigation bar and map buttons that users interact with through the CarPlay screen.

When the user begins to interact with your app through the CarPlay screen, the system displays the navigation bar, hiding it after a brief period of inactivity. You can change this behavior by setting the automaticallyHidesNavigationBar and hidesButtonsWithNavigationBar properties.

The navigation bar includes up to two leading and two trailing buttons. You can change the buttons, including their titles and icon images, by setting the leadingNavigationBarButtons and trailingNavigationBarButtons properties on your template.

You can display additional map buttons by providing an array of CPMapButton objects to mapButtons. Use these buttons to provide users access to actions, such as entering panning mode or zooming in and out on the map.

Topics

Configuring Map Templates

Handling Map Template Events

Managing Map Buttons

Displaying Trip Previews

Navigating a Trip

Providing Trip Estimates

Displaying a Navigation Alert

Panning the Map

See Also

Navigation