This page shows you how to manage collisions between markers that you add to your map and default labels, such as points of interest (POIs) or street names.
Before you begin
To manage marker and label collisions, you must be using a map id.If you're using a bitmap image of a map through lite mode, you can't manage marker and label collisions.
Specifying marker priorities
CollisionBehavior property to specify priority on a
Use one of the following values:
REQUIRED- Default. Requires display of a marker that overlaps with other markers, labels, and POIs.
OPTIONAL_AND_HIDES_LOWER_PRIORITY- Indicates that the marker may be replaced or overlapped by a required marker, or replaced by an
OPTIONAL_AND_HIDES_LOWER_PRIORITYmarker with higher priority. Use
zIndexto help determine relative priority between
OPTIONAL_AND_HIDES_LOWER_PRIORITYmarkers. A higher
zIndexvalue indicates higher priority.
REQUIRED_AND_HIDES_OPTIONAL- Requires display of a marker while hiding any
OPTIONAL_AND_HIDES_LOWER_PRIORITYmarkers, labels, or POIs that overlap with the marker. The marker may overlap with other required markers.
The following code example shows setting
CollisionBehavior for a new marker:
Marker marker = map.addMarker( new MarkerOptions() .position(new LatLng(10, 10)) .zIndex(10) // Optional. .collisionBehavior(Marker.CollisionBehavior.OPTIONAL_AND_HIDES_LOWER_PRIORITY));
val marker = map.addMarker( MarkerOptions() .position(LatLng(10.0, 10.0)) .zIndex(10f) // Optional. .collisionBehavior(Marker.CollisionBehavior.OPTIONAL_AND_HIDES_LOWER_PRIORITY) )