GoogleMarkerClusterer component provides marker clustering using Google’s official @googlemaps/markerclusterer library. This is the recommended clusterer for new projects.
Import
Usage
Props
A render function that receives the Google MarkerClusterer instance and returns the markers to be clustered.
Configuration options for the marker clusterer. This is a subset of
MarkerClustererOptions that omits map and markers (which are managed by the component).Options
Theoptions prop accepts all properties from Google’s MarkerClustererOptions except map and markers:
The clustering algorithm to use. Common algorithms include:
GridAlgorithm- Groups markers into a gridNoopAlgorithm- No clustering (shows all markers)SuperClusterAlgorithm- Fast algorithm for large datasets
Custom renderer for cluster markers. Use this to customize the appearance of cluster icons.
Callback fired when a cluster marker is clicked.
Hook: useGoogleMarkerClusterer
You can also use theuseGoogleMarkerClusterer hook directly for more control:
Hook Parameters
The same options object used by the component.
Returns
The MarkerClusterer instance, or
null if not yet initialized.Types
MarkerClustererOptionsSubset
MarkerClustererOptions from @googlemaps/markerclusterer, excluding the map and markers properties which are managed internally by the component.
Example with Custom Algorithm
Example with Custom Renderer
Comparison with MarkerClusterer
| Feature | GoogleMarkerClusterer | MarkerClusterer |
|---|---|---|
| Package | @googlemaps/markerclusterer | @react-google-maps/marker-clusterer |
| Status | Official Google library | Third-party library |
| Algorithm | Pluggable algorithms | Fixed algorithm |
| Performance | Better for large datasets | Good for moderate datasets |
| Customization | Renderer-based | Style-based |
| Recommendation | Use for new projects | Legacy support |
Notes
- This component uses Google’s official
@googlemaps/markerclustererlibrary. - It provides better performance and more flexibility than the legacy
MarkerClusterer. - The library is actively maintained by Google.
- Markers must be passed the
clustererprop to participate in clustering. - The component automatically manages the lifecycle of the clusterer instance.