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

*** ** * ** ***


```
public final class MapController.Builder
```

<br />

*** ** * ** ***

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

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/car/app/navigation/model/MapController.Builder#Builder()()` |

| ### Public methods |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/navigation/model/MapController` | `https://developer.android.com/reference/androidx/car/app/navigation/model/MapController.Builder#build()()` Constructs the `https://developer.android.com/reference/androidx/car/app/navigation/model/MapController` defined by this builder. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/navigation/model/MapController.Builder` | `https://developer.android.com/reference/androidx/car/app/navigation/model/MapController.Builder#setMapActionStrip(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)` Sets an `https://developer.android.com/reference/androidx/car/app/model/ActionStrip` with a list of map-control related actions for the active template, such as pan or zoom. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/navigation/model/MapController.Builder` | `https://developer.android.com/reference/androidx/car/app/navigation/model/MapController.Builder#setPanModeListener(androidx.car.app.navigation.model.PanModeListener)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/navigation/model/PanModeListener panModeListener)` Sets a `https://developer.android.com/reference/androidx/car/app/navigation/model/PanModeListener` that notifies when the user enters and exits the pan mode. |

## Public constructors

### Builder

Added in 1.2.0

```
public Builder()
```

## Public methods

### build

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

```
public @NonNull MapController build()
```

Constructs the `https://developer.android.com/reference/androidx/car/app/navigation/model/MapController` defined by this builder.

### setMapActionStrip

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

```
public @NonNull MapController.Builder setMapActionStrip(@NonNull ActionStrip actionStrip)
```

Sets an `https://developer.android.com/reference/androidx/car/app/model/ActionStrip` with a list of map-control related actions for the active template, such as pan or zoom.

The host will draw the buttons in an area that is associated with map controls.

If the app does not include the `https://developer.android.com/reference/androidx/car/app/model/Action#PAN()` button in this `https://developer.android.com/reference/androidx/car/app/model/ActionStrip`, the app will not receive the user input for panning gestures from `https://developer.android.com/reference/androidx/car/app/SurfaceCallback` methods, and the host will exit any previously activated pan mode.

#### Requirements

This component allows up to 4 `https://developer.android.com/reference/androidx/car/app/model/Action`s in its map `https://developer.android.com/reference/androidx/car/app/model/ActionStrip`. Only `https://developer.android.com/reference/androidx/car/app/model/Action`s with icons set via `https://developer.android.com/reference/androidx/car/app/model/Action.Builder#setIcon(androidx.car.app.model.CarIcon)` are allowed.

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

### setPanModeListener

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

```
public @NonNull MapController.Builder setPanModeListener(@NonNull PanModeListener panModeListener)
```

Sets a `https://developer.android.com/reference/androidx/car/app/navigation/model/PanModeListener` that notifies when the user enters and exits the pan mode.

If the app does not include the `https://developer.android.com/reference/androidx/car/app/model/Action#PAN()` button in the map `https://developer.android.com/reference/androidx/car/app/model/ActionStrip`, the app will not receive the user input for panning gestures from `https://developer.android.com/reference/androidx/car/app/SurfaceCallback` methods, and the host will exit any previously activated pan mode.

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