<!--
{
  "documentType" : "article",
  "framework" : "MapKitJS",
  "identifier" : "/documentation/MapKitJS/clustering-annotations",
  "metadataVersion" : "0.1.0",
  "role" : "collectionGroup",
  "title" : "Clustering annotations"
}
-->

# Clustering annotations

Combine multiple annotations into a single clustered annotation.

## Discussion

Annotations display coordinate-specific data on a map, typically in the form of markers or images. To declutter annotation-heavy maps, MapKit JS supports *annotation clustering*. As the user zooms out on a map that contains annotations, MapKit JS groups individual annotations into a *cluster annotation* if they collide and if they share the same [`clusteringIdentifier`](/documentation/MapKitJS/Annotation/clusteringIdentifier).

The cluster annotation’s [`memberAnnotations`](/documentation/MapKitJS/Annotation/memberAnnotations) property lists the individual annotations within the cluster. By default, a cluster annotation’s marker displays its member count.

MapKit JS creates cluster annotations automatically. Although you can’t instantiate a cluster annotation, you can customize the look of cluster annotations by providing a delegate method, [`annotationForCluster`](/documentation/MapKitJS/Map/annotationForCluster), to the map.

### Understand the annotations arrays

Although visible on a map, cluster annotations aren’t members of the map’s [`annotations`](/documentation/MapKitJS/Map/annotations) array. The annotations that make up the cluster do belong to the [`annotations`](/documentation/MapKitJS/Map/annotations) array, however, even if they’re not individually visible on the map. For example, the following figure shows a map with annotations A, B, C, D, and E:

![A map showing annotations A, B, C, D, and E with markers.](images/com.apple.mapkitjs/cluster-annotations-01@2x.png)

If the user zooms out so A, B, and C overlap on the map, the annotations combine to create cluster annotation Q, as in the following figure:

![A map showing cluster annotation Q, and annotations D and E. Annotations D and E have markers. Cluster annotation Q has the letters ABC in its marker.](images/com.apple.mapkitjs/cluster-annotations-02@2x.png)

The map displays annotations Q, D, and E, and the resulting annotation arrays are:

- `Q.memberAnnotations = [A, B, C];`
- `map.annotations = [A, B, C, D, E];`

### Set cluster annotation properties

Cluster annotations have the same properties as other annotations, but you can’t set some values, including [`coordinate`](/documentation/MapKitJS/Annotation/coordinate), [`clusteringIdentifier`](/documentation/MapKitJS/Annotation/clusteringIdentifier), and [`draggable`](/documentation/MapKitJS/Annotation/draggable). Other values have specific defaults as the following table shows:

|Property                                                                           |Default for clustering                                         |Description                                                                                                                                                                                                                                                   |
|-----------------------------------------------------------------------------------|---------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|``doc://com.apple.mapkitjs/documentation/MapKitJS/Annotation/title``               |The `title` of the member annotation with the highest priority.|The annotation title text.                                                                                                                                                                                                                                    |
|``doc://com.apple.mapkitjs/documentation/MapKitJS/Annotation/subtitle``            |“`+N` more”, where `N + 1` is the number of member annotations.|The annotation subtitle text.                                                                                                                                                                                                                                 |
|``doc://com.apple.mapkitjs/documentation/MapKitJS/Annotation/coordinate``          |The average of the member annotation coordinates.              |The annotation’s coordinate. The system automatically sets the coordinate of a cluster annotation to the average of all of the contained member annotation coordinates. You can’t change this value; therefore, the user can’t ever drag a cluster annotation.|
|``doc://com.apple.mapkitjs/documentation/MapKitJS/MarkerAnnotation/glyphText``     |`N + 1` (the number of member annotations).                    |The annotation glyph text.                                                                                                                                                                                                                                    |
|``doc://com.apple.mapkitjs/documentation/MapKitJS/Annotation/draggable``           |`false`                                                        |Determines whether the user may drag the annotation. You can’t modify this property.                                                                                                                                                                          |
|``doc://com.apple.mapkitjs/documentation/MapKitJS/Annotation/memberAnnotations``   |NA                                                             |A flat array containing all annotations within the cluster annotation. Only cluster annotations have a `memberAnnotations` property. You can’t modify this property.                                                                                          |
|``doc://com.apple.mapkitjs/documentation/MapKitJS/Annotation/clusteringIdentifier``|`null`                                                         |A shared identifier for all of the member annotations. An annotation needs a `clusteringIdentifier` to be part of an annotation cluster.                                                                                                                      |

## Topics

[`ClusterAnnotation`](/documentation/MapKitJS/ClusterAnnotation)

An annotation type that groups multiple annotations together.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)