Управление поведением при столкновении

Выберите платформу: Android iOS JavaScript

Параметр «Поведение при столкновении» определяет, как отображается маркер, если он сталкивается (перекрывает) другой маркер.

Задайте поведение столкновения для маркера.

Чтобы задать поведение при столкновении, установите для GMSAdvancedMarker.collisionBehavior одно из следующих значений:

  • GMSCollisionBehaviorRequired (По умолчанию): Всегда отображать маркер независимо от столкновения. Это поведение по умолчанию. Не влияет на отображение других маркеров или меток базовой карты.

  • GMSCollisionBehaviorOptionalAndHidesLowerPriority : Отображать маркер только в том случае, если он не перекрывает другие маркеры. Если два маркера этого типа перекрываются, отображается тот, у которого больше zIndex . Если у них одинаковый zIndex , отображается тот, у которого меньше вертикальное положение на экране.

  • GMSCollisionBehaviorRequiredAndHidesOptional : Always display the marker regardless of collision, and hide any GMSCollisionBehaviorOptionalAndHidesLowerPriority . Display the marker only if it does not overlap with other markers. Does not GMSCollisionBehaviorRequired . If two markers of this type would overlap, the one with the higher zIndex is shown. Collision rules for markers with the same zIndex are undefined.

Быстрый

// Defines a marker to always display and hide any marker or label overlay with this marker in the base map
marker.collisionBehavior = .requiredAndHidesOptional

Objective-C

// Defines a marker to always display and hide any marker or label overlay with this marker in the base map
marker.collisionBehavior = GMSCollisionBehaviorRequiredAndHidesOptional