# MapTemplate.Builder

Artifact: [androidx.car.app:app](https://developer.android.com/jetpack/androidx/releases/car-app) [View Source](https://cs.android.com/search?q=file:androidx/car/app/navigation/model/MapTemplate.java+class:androidx.car.app.navigation.model.MapTemplate.Builder) Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.2.0) Deprecated in [1.7.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.7.0)

*** ** * ** ***


```
public final class MapTemplate.Builder
```

<br />

*** ** * ** ***

> [!CAUTION]
> **This class is deprecated.**   
> Deprecated in Java

A builder of `https://developer.android.com/reference/androidx/car/app/navigation/model/MapTemplate`.

## Summary

| ### Public constructors |
|---|
| `[Builder](https://developer.android.com/reference/androidx/car/app/navigation/model/MapTemplate.Builder#Builder())()` **This method is deprecated.** Deprecated in Java |

| ### Public methods |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/navigation/model/MapTemplate` | `[build](https://developer.android.com/reference/androidx/car/app/navigation/model/MapTemplate.Builder#build())()` **This method is deprecated.** Deprecated in Java |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/navigation/model/MapTemplate.Builder` | `[setActionStrip](https://developer.android.com/reference/androidx/car/app/navigation/model/MapTemplate.Builder#setActionStrip(androidx.car.app.model.ActionStrip))(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/ActionStrip actionStrip)` **This method is deprecated.** Deprecated in Java |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/navigation/model/MapTemplate.Builder` | `[setHeader](https://developer.android.com/reference/androidx/car/app/navigation/model/MapTemplate.Builder#setHeader(androidx.car.app.model.Header))(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/Header header)` **This method is deprecated.** Deprecated in Java |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/navigation/model/MapTemplate.Builder` | `[setItemList](https://developer.android.com/reference/androidx/car/app/navigation/model/MapTemplate.Builder#setItemList(androidx.car.app.model.ItemList))(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/ItemList itemList)` **This method is deprecated.** Deprecated in Java |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/navigation/model/MapTemplate.Builder` | `[setMapController](https://developer.android.com/reference/androidx/car/app/navigation/model/MapTemplate.Builder#setMapController(androidx.car.app.navigation.model.MapController))(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/navigation/model/MapController mapController)` **This method is deprecated.** Deprecated in Java |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/navigation/model/MapTemplate.Builder` | `[setPane](https://developer.android.com/reference/androidx/car/app/navigation/model/MapTemplate.Builder#setPane(androidx.car.app.model.Pane))(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/Pane pane)` **This method is deprecated.** Deprecated in Java |

## Public constructors

### Builder

Added in 1.2.0 Deprecated in 1.7.0

```
public [Builder](https://developer.android.com/reference/androidx/car/app/navigation/model/MapTemplate.Builder#Builder())()
```

> [!CAUTION]
> **This method is deprecated.**   
> Deprecated in Java

## Public methods

### build

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.2.0) Deprecated in [1.7.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.7.0)

```
public @NonNull MapTemplate [build](https://developer.android.com/reference/androidx/car/app/navigation/model/MapTemplate.Builder#build())()
```

> [!CAUTION]
> **This method is deprecated.**   
> Deprecated in Java

Constructs the template defined by this builder.

#### Requirements

A `https://developer.android.com/reference/androidx/car/app/model/Pane` and a `https://developer.android.com/reference/androidx/car/app/model/Header` must be set on the component.

The number of items in the `https://developer.android.com/reference/androidx/car/app/model/ItemList` should be smaller or equal than the limit provided by `https://developer.android.com/reference/androidx/car/app/constraints/ConstraintManager#CONTENT_LIMIT_TYPE_PANE()`. The host will ignore any rows over that limit. Each `https://developer.android.com/reference/androidx/car/app/model/Row`s can add up to 2 lines of texts via `https://developer.android.com/reference/androidx/car/app/model/Row.Builder#addText(java.lang.CharSequence)` and cannot contain either a `https://developer.android.com/reference/androidx/car/app/model/Toggle` or a `https://developer.android.com/reference/androidx/car/app/model/OnClickListener`.

Up to 2 `https://developer.android.com/reference/androidx/car/app/model/Action`s are allowed in the `https://developer.android.com/reference/androidx/car/app/model/Pane`. Each action's title color can be customized with `https://developer.android.com/reference/androidx/car/app/model/ForegroundCarColorSpan` instances. Any other span is not supported.

If neither header `https://developer.android.com/reference/androidx/car/app/model/Action` nor title have been set on the template, the header is hidden.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if the `https://developer.android.com/reference/androidx/car/app/model/Pane` does not meet the requirements |
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | if both `https://developer.android.com/reference/androidx/car/app/model/Pane` and `https://developer.android.com/reference/androidx/car/app/model/ItemList` are set or are null. |

### setActionStrip

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.2.0) Deprecated in [1.7.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.7.0)

```
public @NonNull MapTemplate.Builder [setActionStrip](https://developer.android.com/reference/androidx/car/app/navigation/model/MapTemplate.Builder#setActionStrip(androidx.car.app.model.ActionStrip))(@NonNull ActionStrip actionStrip)
```

> [!CAUTION]
> **This method is deprecated.**   
> Deprecated in Java

Sets the `https://developer.android.com/reference/androidx/car/app/model/ActionStrip` for this template.

Unless set with this method, the template will not have an action strip.

The `https://developer.android.com/reference/androidx/car/app/model/Action` buttons in Map Based Template are automatically adjusted based on the screen size. On narrow width screen, icon `https://developer.android.com/reference/androidx/car/app/model/Action`s show by default. If no icon specify, showing title `https://developer.android.com/reference/androidx/car/app/model/Action`s instead. On wider width screen, title `https://developer.android.com/reference/androidx/car/app/model/Action`s show by default. If no title specify, showing icon `https://developer.android.com/reference/androidx/car/app/model/Action`s instead.

#### Requirements

This template allows up to 4 `https://developer.android.com/reference/androidx/car/app/model/Action`s in its `https://developer.android.com/reference/androidx/car/app/model/ActionStrip`. Of the 4 allowed `https://developer.android.com/reference/androidx/car/app/model/Action`s, it can either be a title `https://developer.android.com/reference/androidx/car/app/model/Action` as set via `https://developer.android.com/reference/androidx/car/app/model/Action.Builder#setTitle(java.lang.CharSequence)`, or a icon `https://developer.android.com/reference/androidx/car/app/model/Action` as set via `https://developer.android.com/reference/androidx/car/app/model/Action.Builder#setIcon(androidx.car.app.model.CarIcon)`.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if `actionStrip` does not meet the requirements |
| `https://developer.android.com/reference/java/lang/NullPointerException.html` | if `actionStrip` is `null` |

### setHeader

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.2.0) Deprecated in [1.7.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.7.0)

```
public @NonNull MapTemplate.Builder [setHeader](https://developer.android.com/reference/androidx/car/app/navigation/model/MapTemplate.Builder#setHeader(androidx.car.app.model.Header))(@NonNull Header header)
```

> [!CAUTION]
> **This method is deprecated.**   
> Deprecated in Java

Sets the `https://developer.android.com/reference/androidx/car/app/model/Header` for this template.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException.html` | if `header` is null |

### setItemList

Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.3.0) Deprecated in [1.7.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.7.0)

```
public @NonNull MapTemplate.Builder [setItemList](https://developer.android.com/reference/androidx/car/app/navigation/model/MapTemplate.Builder#setItemList(androidx.car.app.model.ItemList))(@NonNull ItemList itemList)
```

> [!CAUTION]
> **This method is deprecated.**   
> Deprecated in Java

Sets an `https://developer.android.com/reference/androidx/car/app/model/ItemList` to show in a list view along with the map.

Unless set with this method, the template will not show an item list.

To show a marker corresponding to a point of interest represented by a row, set the `https://developer.android.com/reference/androidx/car/app/model/Place` instance via `https://developer.android.com/reference/androidx/car/app/model/Row.Builder#setMetadata(androidx.car.app.model.Metadata)`. The host will display the `https://developer.android.com/reference/androidx/car/app/model/PlaceMarker` in both the map and the list view as the row becomes visible.

#### Requirements

The number of items in the `https://developer.android.com/reference/androidx/car/app/model/ItemList` should be smaller or equal than the limit provided by `https://developer.android.com/reference/androidx/car/app/constraints/ConstraintManager#CONTENT_LIMIT_TYPE_PLACE_LIST()`. The host will ignore any items over that limit. The list itself cannot be selectable as set via `https://developer.android.com/reference/androidx/car/app/model/ItemList.Builder#setOnSelectedListener(androidx.car.app.model.ItemList.OnSelectedListener)`. Each `https://developer.android.com/reference/androidx/car/app/model/Row` can add up to 2 lines of texts via `https://developer.android.com/reference/androidx/car/app/model/Row.Builder#addText(java.lang.CharSequence)` and cannot contain a `https://developer.android.com/reference/androidx/car/app/model/Toggle`.

Images of type `https://developer.android.com/reference/androidx/car/app/model/Row#IMAGE_TYPE_LARGE()` are not allowed in this template.

Rows are not allowed to have both an image and a place marker.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if `itemList` does not meet the template's requirements |
| `https://developer.android.com/reference/java/lang/NullPointerException.html` | if `itemList` is `null` |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/car/app/constraints/ConstraintManager#getContentLimit(int)` |   |

### setMapController

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.2.0) Deprecated in [1.7.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.7.0)

```
public @NonNull MapTemplate.Builder [setMapController](https://developer.android.com/reference/androidx/car/app/navigation/model/MapTemplate.Builder#setMapController(androidx.car.app.navigation.model.MapController))(@NonNull MapController mapController)
```

> [!CAUTION]
> **This method is deprecated.**   
> Deprecated in Java

Sets the `https://developer.android.com/reference/androidx/car/app/navigation/model/MapController` for this template.

### setPane

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.2.0) Deprecated in [1.7.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.7.0)

```
public @NonNull MapTemplate.Builder [setPane](https://developer.android.com/reference/androidx/car/app/navigation/model/MapTemplate.Builder#setPane(androidx.car.app.model.Pane))(@NonNull Pane pane)
```

> [!CAUTION]
> **This method is deprecated.**   
> Deprecated in Java

Sets the `https://developer.android.com/reference/androidx/car/app/model/Pane` for this template. `https://developer.android.com/reference/androidx/car/app/model/Pane#getImage()` for pane will not be shown in `https://developer.android.com/reference/androidx/car/app/navigation/model/MapTemplate`.

Unless set with this method, the template will not show a pane.

#### Requirements

The number of items in the `https://developer.android.com/reference/androidx/car/app/model/Pane` should be smaller or equal than the limit provided by `https://developer.android.com/reference/androidx/car/app/constraints/ConstraintManager#CONTENT_LIMIT_TYPE_PANE()`. The host via `https://developer.android.com/reference/androidx/car/app/model/Row.Builder#addText(java.lang.CharSequence)` and cannot contain either a `https://developer.android.com/reference/androidx/car/app/model/Toggle` or a `https://developer.android.com/reference/androidx/car/app/model/OnClickListener`.

Up to 2 `https://developer.android.com/reference/androidx/car/app/model/Action`s are allowed in the `https://developer.android.com/reference/androidx/car/app/model/Pane`. Each action's title color can be customized with `https://developer.android.com/reference/androidx/car/app/model/ForegroundCarColorSpan` instances. Any other span is not supported.

If none of the header `https://developer.android.com/reference/androidx/car/app/model/Action`, the header title or the action strip have been set on the template, the header is hidden.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if the `https://developer.android.com/reference/androidx/car/app/model/Pane` does not meet the requirements |
| `https://developer.android.com/reference/java/lang/NullPointerException.html` | if `pane` is null |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/car/app/constraints/ConstraintManager#getContentLimit(int)` |   |