# PlaceListMapTemplate.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/model/PlaceListMapTemplate.java+class:androidx.car.app.model.PlaceListMapTemplate.Builder) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.0.0)

*** ** * ** ***

<br />

```
class PlaceListMapTemplate.Builder
```

<br />

*** ** * ** ***

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

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/PlaceListMapTemplate.Builder#Builder()()` Returns an empty `https://developer.android.com/reference/kotlin/androidx/car/app/model/PlaceListMapTemplate.Builder` instance. |

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/PlaceListMapTemplate` | `https://developer.android.com/reference/kotlin/androidx/car/app/model/PlaceListMapTemplate.Builder#build()()` Constructs the template defined by this builder. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/PlaceListMapTemplate.Builder` | `https://developer.android.com/reference/kotlin/androidx/car/app/model/PlaceListMapTemplate.Builder#setActionStrip(androidx.car.app.model.ActionStrip)(actionStrip: https://developer.android.com/reference/kotlin/androidx/car/app/model/ActionStrip)` Sets the `https://developer.android.com/reference/kotlin/androidx/car/app/model/ActionStrip` for this template. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/PlaceListMapTemplate.Builder` | `https://developer.android.com/reference/kotlin/androidx/car/app/model/PlaceListMapTemplate.Builder#setAnchor(androidx.car.app.model.Place)(anchor: https://developer.android.com/reference/kotlin/androidx/car/app/model/Place)` Sets the anchor maker on the map. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/PlaceListMapTemplate.Builder` | `https://developer.android.com/reference/kotlin/androidx/car/app/model/PlaceListMapTemplate.Builder#setCurrentLocationEnabled(boolean)(isEnabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` Sets whether to show the current location in the map. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/PlaceListMapTemplate.Builder` | `https://developer.android.com/reference/kotlin/androidx/car/app/model/PlaceListMapTemplate.Builder#setHeaderAction(androidx.car.app.model.Action)(headerAction: https://developer.android.com/reference/kotlin/androidx/car/app/model/Action)` Sets the `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action` that will be displayed in the header of the template. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/PlaceListMapTemplate.Builder` | `https://developer.android.com/reference/kotlin/androidx/car/app/model/PlaceListMapTemplate.Builder#setItemList(androidx.car.app.model.ItemList)(itemList: https://developer.android.com/reference/kotlin/androidx/car/app/model/ItemList)` Sets an `https://developer.android.com/reference/kotlin/androidx/car/app/model/ItemList` to show in a list view along with the map. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/PlaceListMapTemplate.Builder` | `https://developer.android.com/reference/kotlin/androidx/car/app/model/PlaceListMapTemplate.Builder#setLoading(boolean)(isLoading: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` Sets whether the template is in a loading state. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/PlaceListMapTemplate.Builder` | `@https://developer.android.com/reference/kotlin/androidx/car/app/annotations/RequiresCarApi(value = 5) https://developer.android.com/reference/kotlin/androidx/car/app/model/PlaceListMapTemplate.Builder#setOnContentRefreshListener(androidx.car.app.model.OnContentRefreshListener)( onContentRefreshListener: https://developer.android.com/reference/kotlin/androidx/car/app/model/OnContentRefreshListener )` Sets the `https://developer.android.com/reference/kotlin/androidx/car/app/model/OnContentRefreshListener` to call when the user requests for the list contents to be refreshed in this template. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/PlaceListMapTemplate.Builder` | `https://developer.android.com/reference/kotlin/androidx/car/app/model/PlaceListMapTemplate.Builder#setTitle(androidx.car.app.model.CarText)(title: https://developer.android.com/reference/kotlin/androidx/car/app/model/CarText)` Sets the title of the template, with support for multiple length variants. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/PlaceListMapTemplate.Builder` | `https://developer.android.com/reference/kotlin/androidx/car/app/model/PlaceListMapTemplate.Builder#setTitle(java.lang.CharSequence)(title: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html)` Sets the title of the template. |

## Public constructors

### Builder

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

```
Builder()
```

Returns an empty `https://developer.android.com/reference/kotlin/androidx/car/app/model/PlaceListMapTemplate.Builder` instance.

## Public functions

### build

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

```
fun build(): PlaceListMapTemplate
```

Constructs the template defined by this builder.

#### Requirements

If neither header `https://developer.android.com/reference/kotlin/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 template is in a loading state but the list is set, or vice versa |

### setActionStrip

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

```
fun setActionStrip(actionStrip: ActionStrip): PlaceListMapTemplate.Builder
```

Sets the `https://developer.android.com/reference/kotlin/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/kotlin/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/kotlin/androidx/car/app/model/Action`s show by default. If no icon specify, showing title `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action`s instead. On wider width screen, title `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action`s show by default. If no title specify, showing icon `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action`s instead.

#### Requirements

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

### setAnchor

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

```
fun setAnchor(anchor: Place): PlaceListMapTemplate.Builder
```

Sets the anchor maker on the map.

An anchor marker will not be displayed unless set with this method.

The anchor marker is displayed differently from other markers by the host.

If not `null`, an anchor marker will be shown at the specified `https://developer.android.com/reference/kotlin/androidx/car/app/model/CarLocation` on the map. The camera will adapt to always have the anchor marker visible within its viewport, along with other places' markers from `https://developer.android.com/reference/kotlin/androidx/car/app/model/Row` that are currently visible in the `https://developer.android.com/reference/kotlin/androidx/car/app/model/Pane`. This can be used to provide a reference point on the map (e.g. the center of a search region) as the user pages through the `https://developer.android.com/reference/kotlin/androidx/car/app/model/Pane`'s markers, for example.

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

### setCurrentLocationEnabled

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

```
fun setCurrentLocationEnabled(isEnabled: Boolean): PlaceListMapTemplate.Builder
```

Sets whether to show the current location in the map.

The map template will show the user's current location on the map.

This functionality requires the app to have either the `ACCESS_FINE_LOCATION` or `ACCESS_COARSE_LOCATION` permission. When `isEnabled` is `true`, the host may receive location updates from the app in order to show the user's current location.

### setHeaderAction

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

```
fun setHeaderAction(headerAction: Action): PlaceListMapTemplate.Builder
```

Sets the `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action` that will be displayed in the header of the template.

Unless set with this method, the template will not have a header action.

#### Requirements

This template only supports either one of `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action#APP_ICON()` and `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action#BACK()` as a header `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action`.

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

### setItemList

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

```
fun setItemList(itemList: ItemList): PlaceListMapTemplate.Builder
```

Sets an `https://developer.android.com/reference/kotlin/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/kotlin/androidx/car/app/model/Place` instance via `https://developer.android.com/reference/kotlin/androidx/car/app/model/Row.Builder#setMetadata(androidx.car.app.model.Metadata)`. The host will display the `https://developer.android.com/reference/kotlin/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/kotlin/androidx/car/app/model/ItemList` should be smaller or equal than the limit provided by `https://developer.android.com/reference/kotlin/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/kotlin/androidx/car/app/model/ItemList.Builder#setOnSelectedListener(androidx.car.app.model.ItemList.OnSelectedListener)`. Each `https://developer.android.com/reference/kotlin/androidx/car/app/model/Row` can add up to 2 lines of texts via `https://developer.android.com/reference/kotlin/androidx/car/app/model/Row.Builder#addText(java.lang.CharSequence)` and cannot contain a `https://developer.android.com/reference/kotlin/androidx/car/app/model/Toggle`.

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

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

All non-browsable rows must have a `https://developer.android.com/reference/kotlin/androidx/car/app/model/DistanceSpan` attached to either its title or texts to indicate the distance of the point of interest from the current location. A row is browsable when it's configured like so with `https://developer.android.com/reference/kotlin/androidx/car/app/model/Row.Builder#setBrowsable(boolean)`.

| 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/kotlin/androidx/car/app/constraints/ConstraintManager#getContentLimit(int)` |   |

### setLoading

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

```
fun setLoading(isLoading: Boolean): PlaceListMapTemplate.Builder
```

Sets whether the template is in a loading state.

If set to `true`, the UI will display a loading indicator where the list content would be otherwise. The caller is expected to call `https://developer.android.com/reference/kotlin/androidx/car/app/Screen#invalidate()` and send the new template content to the host once the data is ready. If set to `false`, the UI shows the `https://developer.android.com/reference/kotlin/androidx/car/app/model/ItemList` contents added via `https://developer.android.com/reference/kotlin/androidx/car/app/model/PlaceListMapTemplate.Builder#setItemList(androidx.car.app.model.ItemList)`.

### setOnContentRefreshListener

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

```
@RequiresCarApi(value = 5)
fun setOnContentRefreshListener(
    onContentRefreshListener: OnContentRefreshListener
): PlaceListMapTemplate.Builder
```

Sets the `https://developer.android.com/reference/kotlin/androidx/car/app/model/OnContentRefreshListener` to call when the user requests for the list contents to be refreshed in this template.

When the listener is triggered, an app can send a new `https://developer.android.com/reference/kotlin/androidx/car/app/model/PlaceListMapTemplate`, for example, to show a new set of point-of-interests based on the current user location, without the car host counting it against the template quota described in `https://developer.android.com/reference/kotlin/androidx/car/app/Screen#onGetTemplate()`.

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

### setTitle

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

```
fun setTitle(title: CarText): PlaceListMapTemplate.Builder
```

Sets the title of the template, with support for multiple length variants.

Only `https://developer.android.com/reference/kotlin/androidx/car/app/model/DistanceSpan`s and `https://developer.android.com/reference/kotlin/androidx/car/app/model/DurationSpan`s are supported in the input string.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException.html` | if `title` is null |
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if `title` contains unsupported spans |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/CarText` |   |

### setTitle

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

```
fun setTitle(title: CharSequence): PlaceListMapTemplate.Builder
```

Sets the title of the template.

Only `https://developer.android.com/reference/kotlin/androidx/car/app/model/DistanceSpan`s and `https://developer.android.com/reference/kotlin/androidx/car/app/model/DurationSpan`s are supported in the input string.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException.html` | if `title` is null |
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if `title` contains unsupported spans |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/CarText` |   |