> For the complete documentation index, see [llms.txt](https://docs.mapsindoors.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.mapsindoors.com/sdks-and-frameworks/android/displaying-objects/turn-off-collisions-based-on-zoom-level-1.md).

# Turn Off Collisions Based on Zoom Level

When using the MapsIndoors SDK, the system for detecting collisions will sometimes, at high zoom levels, result in the Labels of POI's that are close together being hidden, no matter what you do. Here we present a small workaround, so you can disable collisions for specific zoom levels.

For Android, there are two ways of implementing this, and which you should use depends on your desired map behavior.

#### Google Maps for Android​ <a href="#google-maps-for-android" id="google-maps-for-android"></a>

If you wish for the collision behavior to change when the maps stops moving, you should use this piece of code. This would generally be the most performance-friendly option.

```kotlin
val maxZoomForCollisions = 20 //set your desired zoom level upon which the collision behaviour changes

mGoogleMap.setOnCameraIdleListener {
    if (mGoogleMap.cameraPosition.zoom >= maxZoomForCollisions) {
        MapsIndoors.getSolution()?.config?.setCollisionHandling(MPCollisionHandling.ALLOW_OVERLAP)
    } else {
        MapsIndoors.getSolution()?.config?.setCollisionHandling(MPCollisionHandling.REMOVE_LABEL_FIRST)
    }
}
```

However, if you wish for the collision behavior to change when the maps starts moving instead, you should use this.

```kotlin
val maxZoomForCollisions = 20 //set your desired zoom level upon which the collision behaviour changes

mGoogleMap.setOnCameraMoveListener {
    if (mGoogleMap.cameraPosition.zoom >= maxZoomForCollisions) {
        MapsIndoors.getSolution()?.config?.setCollisionHandling(MPCollisionHandling.ALLOW_OVERLAP)
    } else {
        MapsIndoors.getSolution()?.config?.setCollisionHandling(MPCollisionHandling.REMOVE_LABEL_FIRST)
    }
}
```

#### Mapbox for Android​ <a href="#mapbox-for-android" id="mapbox-for-android"></a>

The code for Mapbox is somewhat different - Here you must make an `onMoveListener`, and insert the implementation into the relevant section - `onMove`, `onMoveBegin` or `onMoveEnd`. Generally, `onMoveEnd` would be recommended, and will be shown below, as it is the most performance-friendly, but code may be moved into the others, if your specific functionality can be achieved through this.

```kotlin
val maxZoomForCollisions = 20

mMapBoxMap?.addOnMoveListener(object : OnMoveListener {
    override fun onMove(detector: MoveGestureDetector): Boolean {
      // insert implementation here if desired
      return false
    }

    override fun onMoveBegin(detector: MoveGestureDetector) {
      // insert implementation here if desired
    }

    override fun onMoveEnd(detector: MoveGestureDetector) {
        // the implementation starts here
        if (mMapBoxMap?.cameraState?.zoom!! >= maxZoomForCollisions) {
            MapsIndoors.getSolution()?.config?.setCollisionHandling(MPCollisionHandling.ALLOW_OVERLAP)
        } else {
            MapsIndoors.getSolution()?.config?.setCollisionHandling(MPCollisionHandling.REMOVE_LABEL_FIRST)
        }
        // the implementation ends here
    }

})
```

[<br>](https://docs.mapsindoors.com/location-details)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.mapsindoors.com/sdks-and-frameworks/android/displaying-objects/turn-off-collisions-based-on-zoom-level-1.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
