![3D image of New York City featuring the Empire State Building with three custom digital markers floating above it, including a cartoon gorilla labeled](https://developers.google.com/static/maps/documentation/maps-3d/android-sdk/images/custom-markers-android.png)

You can use
[`MarkerView`](https://developers.google.com/maps/documentation/maps-3d/android-sdk/reference/com/google/android/gms/maps3d/model/MarkerView.md.txt)
to render custom Android `View` hierarchies as markers on a 3D map. Custom view
markers let you display rich UI layouts, interactive widgets, and view
animations anchored to geographic coordinates.

> [!NOTE]
> **Note:** Custom view markers ([`MarkerView`](https://developers.google.com/maps/documentation/maps-3d/android-sdk/reference/com/google/android/gms/maps3d/model/MarkerView.md.txt)) offer greater customization and interactivity than standard 3D markers ([`Marker`](https://developers.google.com/maps/documentation/maps-3d/android-sdk/reference/com/google/android/gms/maps3d/model/Marker.md.txt)), which render with lower overhead. For applications with large numbers of markers, standard [`Marker`](https://developers.google.com/maps/documentation/maps-3d/android-sdk/reference/com/google/android/gms/maps3d/model/Marker.md.txt) instances added with [`addMarker`](https://developers.google.com/maps/documentation/maps-3d/android-sdk/reference/com/google/android/gms/maps3d/GoogleMap3D.md.txt#addMarker(com.google.android.gms.maps3d.model.MarkerOptions)) are recommended to maintain optimal performance.

## Add a custom view marker

To add a custom view marker to your map, create a
[`MarkerViewOptions`](https://developers.google.com/maps/documentation/maps-3d/android-sdk/reference/com/google/android/gms/maps3d/model/MarkerViewOptions.md.txt)
instance, configure its location with
[`setPosition`](https://developers.google.com/maps/documentation/maps-3d/android-sdk/reference/com/google/android/gms/maps3d/model/MarkerViewOptions.md.txt#setPosition(com.google.android.gms.maps3d.model.LatLngAltitude))
using a
[`LatLngAltitude`](https://developers.google.com/maps/documentation/maps-3d/android-sdk/reference/com/google/android/gms/maps3d/model/LatLngAltitude.md.txt)
object, and supply your custom Android `View` using
[`setContent`](https://developers.google.com/maps/documentation/maps-3d/android-sdk/reference/com/google/android/gms/maps3d/model/MarkerViewOptions.md.txt#setContent(android.view.View)).
Then, pass the options to
[`addMarkerView`](https://developers.google.com/maps/documentation/maps-3d/android-sdk/reference/com/google/android/gms/maps3d/GoogleMap3D.md.txt#addMarkerView(com.google.android.gms.maps3d.model.MarkerViewOptions))
on your
[`GoogleMap3D`](https://developers.google.com/maps/documentation/maps-3d/android-sdk/reference/com/google/android/gms/maps3d/GoogleMap3D.md.txt)
instance.

If you don't provide a view to
[`setContent`](https://developers.google.com/maps/documentation/maps-3d/android-sdk/reference/com/google/android/gms/maps3d/model/MarkerViewOptions.md.txt#setContent(android.view.View)),
the SDK creates and renders a default
[`PinView`](https://developers.google.com/maps/documentation/maps-3d/android-sdk/reference/com/google/android/gms/maps3d/model/PinView.md.txt).

```kotlin
// Add imports
import android.widget.TextView
import com.google.android.gms.maps3d.model.MarkerViewOptions
import com.google.android.gms.maps3d.model.latLngAltitude

// Create a custom Android View
val badgeView = TextView(context).apply {
    text = "Empire State Building"
    contentDescription = "Marker for Empire State Building"
    setPadding(24, 12, 24, 12)
}

// Configure MarkerViewOptions and add the marker view to the map
val options = MarkerViewOptions().apply {
    position = latLngAltitude {
        latitude = 40.7484
        longitude = -73.9857
        altitude = 100.0
    }
    content = badgeView
}

val markerView = googleMap3D.addMarkerView(options)
```

### Customize the default PinView

Instead of building a completely custom Android `View`, you can render a
customized pin by creating a
[`PinView`](https://developers.google.com/maps/documentation/maps-3d/android-sdk/reference/com/google/android/gms/maps3d/model/PinView.md.txt)
with a custom
[`PinConfiguration`](https://developers.google.com/maps/documentation/maps-3d/android-sdk/reference/com/google/android/gms/maps3d/model/PinConfiguration.md.txt)
(or updating an existing instance with
[`setPinConfiguration`](https://developers.google.com/maps/documentation/maps-3d/android-sdk/reference/com/google/android/gms/maps3d/model/PinView.md.txt#setPinConfiguration(com.google.android.gms.maps3d.model.PinConfiguration)))
and passing it to
[`setContent`](https://developers.google.com/maps/documentation/maps-3d/android-sdk/reference/com/google/android/gms/maps3d/model/MarkerViewOptions.md.txt#setContent(android.view.View)).

```kotlin
// Add imports
import android.graphics.Color
import com.google.android.gms.maps3d.model.MarkerViewOptions
import com.google.android.gms.maps3d.model.PinView
import com.google.android.gms.maps3d.model.latLngAltitude
import com.google.android.gms.maps3d.model.pinConfiguration

// Create a customized PinView
val customPinView = PinView(context, pinConfiguration {
    backgroundColor = Color.BLUE
    borderColor = Color.WHITE
})

// Configure MarkerViewOptions and add the marker view to the map
val options = MarkerViewOptions().apply {
    position = latLngAltitude {
        latitude = 40.7484
        longitude = -73.9857
        altitude = 100.0
    }
    content = customPinView
}

val markerView = googleMap3D.addMarkerView(options)
```

## Handle interactions and animations

Because a
[`MarkerView`](https://developers.google.com/maps/documentation/maps-3d/android-sdk/reference/com/google/android/gms/maps3d/model/MarkerView.md.txt)
wraps an Android `View`, you can attach standard click listeners and view
animations directly to the view returned by
[`getContent`](https://developers.google.com/maps/documentation/maps-3d/android-sdk/reference/com/google/android/gms/maps3d/model/MarkerView.md.txt).

In addition,
[`MarkerView`](https://developers.google.com/maps/documentation/maps-3d/android-sdk/reference/com/google/android/gms/maps3d/model/MarkerView.md.txt)
implements
[`Anchorable`](https://developers.google.com/maps/documentation/maps-3d/android-sdk/reference/com/google/android/gms/maps3d/model/Anchorable.md.txt),
which lets you anchor a
[`Popover`](https://developers.google.com/maps/documentation/maps-3d/android-sdk/reference/com/google/android/gms/maps3d/Popover.md.txt)
to the marker view using
[`addPopover`](https://developers.google.com/maps/documentation/maps-3d/android-sdk/reference/com/google/android/gms/maps3d/GoogleMap3D.md.txt#addPopover(com.google.android.gms.maps3d.model.PopoverOptions)):

```kotlin
markerView?.content?.setOnClickListener { view ->
    // Animate the view when clicked
    view.animate().rotationBy(90f).setDuration(300).start()
}
```

## Configure altitude and collision behavior

You can customize how a
[`MarkerView`](https://developers.google.com/maps/documentation/maps-3d/android-sdk/reference/com/google/android/gms/maps3d/model/MarkerView.md.txt)
is positioned vertically and how it interacts with overlapping map labels or
markers:

- **Altitude mode** : Call [`setAltitudeMode`](https://developers.google.com/maps/documentation/maps-3d/android-sdk/reference/com/google/android/gms/maps3d/model/MarkerViewOptions.md.txt#setAltitudeMode(int)) on [`MarkerViewOptions`](https://developers.google.com/maps/documentation/maps-3d/android-sdk/reference/com/google/android/gms/maps3d/model/MarkerViewOptions.md.txt) with an [`AltitudeMode`](https://developers.google.com/maps/documentation/maps-3d/android-sdk/reference/com/google/android/gms/maps3d/model/AltitudeMode.md.txt) constant. By default, [`MarkerViewOptions`](https://developers.google.com/maps/documentation/maps-3d/android-sdk/reference/com/google/android/gms/maps3d/model/MarkerViewOptions.md.txt) uses [`AltitudeMode.CLAMP_TO_GROUND`](https://developers.google.com/maps/documentation/maps-3d/android-sdk/reference/com/google/android/gms/maps3d/model/AltitudeMode.md.txt#CLAMP_TO_GROUND()).
- **Collision behavior** : Call [`setCollisionBehavior`](https://developers.google.com/maps/documentation/maps-3d/android-sdk/reference/com/google/android/gms/maps3d/model/MarkerViewOptions.md.txt#setCollisionBehavior(int)) with a [`CollisionBehavior`](https://developers.google.com/maps/documentation/maps-3d/android-sdk/reference/com/google/android/gms/maps3d/model/CollisionBehavior.md.txt) constant (defaults to [`CollisionBehavior.REQUIRED`](https://developers.google.com/maps/documentation/maps-3d/android-sdk/reference/com/google/android/gms/maps3d/model/CollisionBehavior.md.txt#REQUIRED())), and use [`setCollisionPriority`](https://developers.google.com/maps/documentation/maps-3d/android-sdk/reference/com/google/android/gms/maps3d/model/MarkerViewOptions.md.txt#setCollisionPriority(int)) to specify display priority when markers collide.

## Accessibility and removal

You are responsible for configuring accessibility properties---such as
`contentDescription`---on the custom Android `View` supplied to
[`setContent`](https://developers.google.com/maps/documentation/maps-3d/android-sdk/reference/com/google/android/gms/maps3d/model/MarkerViewOptions.md.txt#setContent(android.view.View)).

To remove a
[`MarkerView`](https://developers.google.com/maps/documentation/maps-3d/android-sdk/reference/com/google/android/gms/maps3d/model/MarkerView.md.txt)
from the map, call
[`remove`](https://developers.google.com/maps/documentation/maps-3d/android-sdk/reference/com/google/android/gms/maps3d/model/MarkerView.md.txt#remove()):

```kotlin
markerView?.remove()
```