MGLCluster

@protocol MGLCluster <MGLFeature>

A protocol that feature subclasses (i.e. those already conforming to the MGLFeature protocol) conform to if they represent clusters.

Currently the only class that conforms to MGLCluster is MGLPointFeatureCluster (a subclass of MGLPointFeature).

To check if a feature is a cluster, check conformity to MGLCluster, for example:

let shape = try! MGLShape(data: clusterShapeData, encoding: String.Encoding.utf8.rawValue)

guard let pointFeature = shape as? MGLPointFeature else {
    throw ExampleError.unexpectedFeatureType
}

// Check for cluster conformance
guard let cluster = pointFeature as? MGLCluster else {
    throw ExampleError.featureIsNotACluster
}

// Currently the only supported class that conforms to `MGLCluster` is
// `MGLPointFeatureCluster`
guard cluster is MGLPointFeatureCluster else {
    throw ExampleError.unexpectedFeatureType
}
  • The identifier for the cluster.

    Declaration

    Objective-C

    @property (readonly, nonatomic) NSUInteger clusterIdentifier;

    Swift

    var clusterIdentifier: UInt { get }
  • The number of points within this cluster

    Declaration

    Objective-C

    @property (readonly, nonatomic) NSUInteger clusterPointCount;

    Swift

    var clusterPointCount: UInt { get }