A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developers.google.com/maps/documentation/android-sdk/advanced-markers/collision-behavior below:

Collision behavior | Maps SDK for Android

Collision behavior

Stay organized with collections Save and categorize content based on your preferences.

This page shows you how to control the collision behavior for a marker.

Set collision behavior for a marker

Collision behavior controls how a marker displays if it collides (overlaps) with another marker. The way you create an advanced markers determines how collision behavior works:

Note: For optimal collision behavior, you should create all advanced markers of the same type. That is, if you are using a view marker for one marker then you should use view markers for all of them.

To set collision behavior, set AdvancedMarkerOptions.collisionBehavior to one of the following:

The following example shows setting collision behavior for a marker:

Kotlin
// Collision behavior can only be changed in the AdvancedMarkerOptions object.
// Changes to collision behavior after a marker has been created are not possible
val collisionBehavior: Int = CollisionBehavior.REQUIRED_AND_HIDES_OPTIONAL
val advancedMarkerOptions: AdvancedMarkerOptions = AdvancedMarkerOptions()
    .position(LatLng(10.0, 10.0))
    .collisionBehavior(collisionBehavior)

val marker: Marker = map.addMarker(advancedMarkerOptions) ?: error("Failed to add marker")

      
Java
// Collision behavior can only be changed in the AdvancedMarkerOptions object.
// Changes to collision behavior after a marker has been created are not possible
int collisionBehavior = AdvancedMarkerOptions.CollisionBehavior.REQUIRED_AND_HIDES_OPTIONAL;
AdvancedMarkerOptions options = new AdvancedMarkerOptions()
        .position(new LatLng(10.0, 10.0))
        .collisionBehavior(collisionBehavior);

Marker marker = map.addMarker(options);

      

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-08-14 UTC.

[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-14 UTC."],[[["This page explains how to manage marker collision behavior on maps using `AdvancedMarkerOptions.collisionBehavior`."],["Collision behavior dictates how markers are displayed when they overlap, with options including `REQUIRED`, `REQUIRED_AND_HIDES_OPTIONAL`, and `OPTIONAL_AND_HIDES_LOWER_PRIORITY`."],["Marker types (bitmap and view) influence collision behavior, with view markers drawn on top of bitmap markers, and zIndex playing a role in determining visibility during overlaps."],["For consistent collision handling, it's recommended to use the same marker type (either all bitmap or all view) for all markers on the map."]]],[]]


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4