This page demonstrates how to set the collision behavior for a marker. Collision behavior controls how a marker will display if it collides (overlaps) with another marker.
To set collision behavior, set collisionBehavior
to one of the following:
-
REQUIRED: Always display the marker regardless of collision -
REQUIRED_AND_HIDES_OPTIONAL: Always display the marker regardless of collision, and hide anyOPTIONAL_AND_HIDES_LOWER_PRIORITYmarkers or labels that would overlap with the marker. -
OPTIONAL_AND_HIDES_LOWER_PRIORITY: Display the marker only if it does not overlap with other markers. If two markers of this type would overlap, the one with the higherzIndexis shown. If they have the samezIndex, the one with the lower vertical screen position is shown.
The following example shows setting collision behavior for a marker:
const
marker
=
new
Marker3DElement
({
position
:
{
lat
,
lng
},
collisionBehavior
:
google
.
maps
.
CollisionBehavior
.
REQUIRED
});

