You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
| background |`string`| Please refer to the <ahref='https://developers.google.com/maps/documentation/javascript/reference/advanced-markers#PinElement-Properties'target='_blank'rel='noreferrer'>official documentation</a>. |
`<MarkerClusterer />` component is used for combine markers of close proximity into clusters, and simplify the display of markers on the map.
9
+
10
+
`MarkerClusterer` is based on <ahref='https://www.npmjs.com/package/@googlemaps/markerclusterer'target='_blank'rel='noreferrer'>@googlemaps/markerclusterer</a>. for more detail, see ~our MarkerClusterer example~ or <ahref='https://googlemaps.github.io/js-markerclusterer'target='_blank'rel='noreferrer'>official library documentation</a>.
11
+
12
+
### Basic Example
13
+
14
+
```tsx
15
+
const locations = [
16
+
{ lat: -31.56391, lng: 147.154312 },
17
+
{ lat: -33.718234, lng: 150.363181 },
18
+
{ lat: -33.727111, lng: 150.371124 },
19
+
{ lat: -33.848588, lng: 151.209834 },
20
+
{ lat: -33.851702, lng: 151.216968 },
21
+
{ lat: -34.671264, lng: 150.863657 },
22
+
{ lat: -35.304724, lng: 148.662905 },
23
+
{ lat: -36.817685, lng: 175.699196 },
24
+
{ lat: -36.828611, lng: 175.790222 },
25
+
{ lat: -37.75, lng: 145.116667 },
26
+
{ lat: -37.759859, lng: 145.128708 },
27
+
{ lat: -37.765015, lng: 145.133858 },
28
+
{ lat: -37.770104, lng: 145.143299 },
29
+
{ lat: -37.7737, lng: 145.145187 },
30
+
{ lat: -37.774785, lng: 145.137978 },
31
+
{ lat: -37.819616, lng: 144.968119 },
32
+
{ lat: -38.330766, lng: 144.695692 },
33
+
{ lat: -39.927193, lng: 175.053218 },
34
+
{ lat: -41.330162, lng: 174.865694 },
35
+
{ lat: -42.734358, lng: 147.439506 },
36
+
{ lat: -42.734358, lng: 147.501315 },
37
+
{ lat: -42.735258, lng: 147.438 },
38
+
{ lat: -43.999792, lng: 170.463352 },
39
+
];
40
+
41
+
function MyMap() {
42
+
return (
43
+
<GoogleMap
44
+
zoom={3}
45
+
center={{ lat: -28.024, lng: 140.887 }}
46
+
{...}
47
+
>
48
+
<MarkerClusterer>
49
+
{locations.map(({ lat, lng }, i) => (
50
+
<Marker
51
+
key={i}
52
+
lat={lat}
53
+
lng={lng}
54
+
/>
55
+
))}
56
+
</MarkerClusterer>
57
+
</GoogleMap>
58
+
);
59
+
}
60
+
```
61
+
62
+
<MarkerClustererExclient:only='react' />
63
+
64
+
### Props
65
+
66
+
> props are the same as <ahref='https://github.com/googlemaps/js-markerclusterer/blob/main/src/markerclusterer.ts#L32-L48'target='_blank'rel='noreferrer'>MarkerClustererOptions</a>. (`map` and `markers` are automatically filled)
67
+
68
+
we highly recommend memorizing props. If you don't, `MarkerClusterer` will be re-created every time.
69
+
70
+
| Props | Type | Description |
71
+
| ----------- | ----------- | ----------- |
72
+
| algorithmOptions |`AlgorithmOptions`| An options for Algorithm. |
73
+
| algorithm |`Algorithm`| An algorithm to cluster markers. Default is <ahref='https://googlemaps.github.io/js-markerclusterer/classes/SuperClusterAlgorithm.html'target='_blank'rel='noreferrer'>SuperClusterAlgorithm</a>. |
74
+
| renderer |`Renderer`| An object that converts a Cluster into a `google.maps.Marker`. |
0 commit comments