Skip to content

Document per-marker cluster={false} behavior #297

Description

@sutgeorge

Document per-marker cluster={false} behavior

Summary

The library supports excluding individual markers from clustering by passing cluster={false} to the marker child rendered inside ClusteredMapView, but this behavior does not appear to be documented in the README/API docs.

This is useful for cases where most markers should be clustered, but specific markers need to remain visible as standalone markers.

Current behavior

The behavior exists in the source code. In lib/helpers.js, isMarker only treats a child as clusterable when:

child &&
child.props &&
child.props.coordinate &&
child.props.cluster !== false

So a marker like this is excluded from the Supercluster input:

<Marker
  coordinate={{ latitude: 44.4759, longitude: -73.2121 }}
  cluster={false}
/>

This marker is still rendered normally, but it is not added to the cluster index.

Why this is useful

This enables mixed clustering behavior:

<MapView clusteringEnabled>
  <Marker coordinate={regularMarkerCoordinate} />

  <Marker
    coordinate={highlightedMarkerCoordinate}
    cluster={false}
  />
</MapView>

Expected result:

  • regular markers are clustered
  • markers with cluster={false} stay separate
  • the app does not need to disable clustering globally

This is especially helpful for highlighted locations, promoted markers, selected locations, or markers that should not be merged into nearby clusters.

Documentation request

Please document cluster={false} as a supported marker-level prop.

A possible README addition could be:

### Disable clustering for a specific marker

You can exclude an individual marker from clustering by passing `cluster={false}` to the marker:

```tsx
<MapView clusteringEnabled>
  <Marker coordinate={regularMarkerCoordinate} />

  <Marker
    coordinate={highlightedMarkerCoordinate}
    cluster={false}
  />
</MapView>

Markers with cluster={false} are rendered normally, but they are not added to the cluster index.


### Notes

This behavior is very useful, but currently it is only discoverable by reading the source. Adding it to the README would make the feature much easier to find and would clarify that `cluster` is consumed by `react-native-map-clustering`, not by `react-native-maps`.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions