public class MapMarkerCluster
extension MapMarkerCluster: NativeBase
extension MapMarkerCluster: Hashable

Groups map markers and enables their clustering to reduce visual clutter when there are many of them in a small area.

The markers that are close to each other are replaced by a single cluster marker. Cluster groups are generated based on geographical distance between objects, not based on screen space collision. Hence it is possible, that cluster markers can overlap.

The markers can be added to a cluster or to a scene, but not to both. To display the cluster on the map, add it to the scene using MapScene.addMapMarkerCluster(...). The display of a cluster is only guaranteed in case its origin is within the viewport. At the moment, this is a known limitation that mostly affects clusters which are visually large and cover a sizeable part of the viewport.

Markers part of the cluster with opacity set to zero are still on the map and are considered for picking and clustering.

  • Creates a new instance of a map marker cluster which is represented as an image.

    Any modification to object passed as imageStyle after creation of MapMarkerCluster does not have any effect.

    Declaration

    Swift

    public init(imageStyle: MapMarkerCluster.ImageStyle)

    Parameters

    imageStyle

    The visual representation for the cluster.

  • Creates a new instance of a map marker cluster which is represented as an image along with a counter showing how many markers are actually grouped under particular cluster icon.

    Any modification to imageStyle or counterStyle after creation of MapMarkerCluster does not have any effect.

    Declaration

    Swift

    public init(imageStyle: MapMarkerCluster.ImageStyle, counterStyle: MapMarkerCluster.CounterStyle)

    Parameters

    imageStyle

    Describes the visual appearance of cluster icon.

    counterStyle

    Describes the appearance of marker count label.

  • The list of map markers which currently belong to this cluster. Modifying the list has no effect on the marker cluster.

    Declaration

    Swift

    public var markers: [MapMarker] { get }
  • Opacity is the factor which is applied to the alpha channel of the image used for marker cluster. The value is clamped in range [0.0, 1.0]. Default value is 1.0 which means marker cluster is displayed with the default opacity of the image.

    Marker clusters with opacity value set to 0.0 are still on map and are considered for picking.

    Markers part of cluster will use their respective opacity when not displayed as a cluster icon.

    Declaration

    Swift

    public var opacity: Double { get set }
  • Represents a group of map markers belonging to a cluster.

    It contains a list of map markers grouped on map view under single icon of marker cluster or single map marker entry for markers being part of cluster but spread enough not to be grouped.

    See more

    Declaration

    Swift

    public struct Grouping
  • This class specifies the visual appearance of a cluster marker.

    See more

    Declaration

    Swift

    public struct ImageStyle
  • Styling options for a marker cluster which is represented by the marker count as a text.

    See more

    Declaration

    Swift

    public struct CounterStyle
  • Adds a map marker to this cluster. Adding a marker which is already part of the cluster or which was already added to the map scene has no effect.

    Declaration

    Swift

    public func addMapMarker(marker: MapMarker)

    Parameters

    marker

    The marker.

  • Adds a list of map markers to this cluster.

    Markers which are already part of the cluster or which were already added to the map scene will be ignored.

    Declaration

    Swift

    public func addMapMarkers(markers: [MapMarker])

    Parameters

    markers

    The list of markers.

  • Removes a map marker from this cluster.

    Removing a marker which is not part of this cluster has no effect.

    Declaration

    Swift

    public func removeMapMarker(marker: MapMarker)

    Parameters

    marker

    The marker.

  • Removes a list of map markers from this cluster.

    Removing markers which are not part of this cluster has no effect.

    Declaration

    Swift

    public func removeMapMarkers(markers: [MapMarker])

    Parameters

    markers

    The list of markers.

  • Removes all map markers from this cluster.

    Declaration

    Swift

    public func removeAllMapMarkers()