Select platform: [Android](https://developers.google.com/maps/documentation/maps-3d/android-sdk/configure-marker-collision-behavior.md.txt "View this page for the Android platform docs.") [iOS](https://developers.google.com/maps/documentation/maps-3d/ios-sdk/configure-marker-collision-behavior.md.txt "View this page for the iOS platform docs.") [JavaScript](https://developers.google.com/maps/documentation/javascript/3d/marker-collision.md.txt "View this page for the JavaScript platform docs.")

<br />

You can specify how a marker should behave when it collides with another
marker or map label by setting the
[`collisionBehavior`](https://developers.google.com/maps/documentation/maps-3d/android-sdk/reference/com/google/android/gms/maps3d/model/CollisionBehavior.md.txt)
property to one of the following values:

- `REQUIRED`: The marker should always be displayed regardless of collisions.
- `REQUIRED_AND_HIDES_OPTIONAL`: The marker should always be displayed regardless of collisions. Markers with `OPTIONAL_AND_HIDES_LOWER_PRIORITY` collision behavior or the default map labels that overlap with this marker will be hidden.
- `OPTIONAL_AND_HIDES_LOWER_PRIORITY`: The marker should only be displayed if it does not overlap with other markers. If two markers of this type would overlap, the one with the higher draw order is shown. If they have the same draw order, the one with the lower vertical screen position is shown.

The following code sample demonstrates each of the collision behavior values. To
use this code sample, follow the instructions in
[Setup](https://developers.google.com/maps/documentation/maps-3d/android-sdk/setup.md.txt) and [Add a 3D map to your
app](https://developers.google.com/maps/documentation/maps-3d/android-sdk/add-a-3d-map) to set up your
Android Studio project with a basic 3D map. Then, add the following code to the
`MainActivity.kt` file:

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

...

// Marker 1: REQUIRED
googleMap3D.addMarker(markerOptions {
    position = latLngAltitude {
        latitude = 52.52027645136134
        longitude = 13.408271658592406
        altitude = 0.0
    }
    label = "Collision Behavior: REQUIRED"
    altitudeMode = AltitudeMode.CLAMP_TO_GROUND
    isExtruded = true
    isDrawnWhenOccluded = true
    collisionBehavior = CollisionBehavior.REQUIRED
})

// Marker 2: REQUIRED_AND_HIDES_OPTIONAL
googleMap3D.addMarker(markerOptions {
    position = latLngAltitude {
        latitude = 52.519605780912585
        longitude = 13.406867190588198
        altitude = 150.0
    }
    label = "Colliding Behavior: REQUIRED_AND_HIDES_OPTIONAL"
    altitudeMode = AltitudeMode.ABSOLUTE
    isExtruded = true
    isDrawnWhenOccluded = true
    collisionBehavior = CollisionBehavior.REQUIRED_AND_HIDES_OPTIONAL
})

// Marker 3: OPTIONAL_AND_HIDES_LOWER_PRIORITY
googleMap3D.addMarker(markerOptions {
    position = latLngAltitude {
        latitude = 52.519882191069016
        longitude = 13.407410777254293
        altitude = 50.0
    }
    label = "Colliding Behavior: OPTIONAL_AND_HIDES_LOWER_PRIORITY"
    altitudeMode = AltitudeMode.RELATIVE_TO_GROUND
    isExtruded = true
    isDrawnWhenOccluded = true
    collisionBehavior = CollisionBehavior.OPTIONAL_AND_HIDES_LOWER_PRIORITY
})
```