I'm trying to figure out how to set the maxZoom attribute.
I found the list of acceptable arguments:
new MarkerClusterer({ map, markers, algorithm, renderer, onClusterClick })
So, I don't want to implement my own algorithm. The default one I guess pretty cool.
I found the maxZoom
property in the documentation. But cannot understand how to pass it to the MarkerClusterer object.
I saw this question, but looks like the MarkerClusterer implementation have changed and the answer is outdated. The MarkerClusterer object accepts only one argument with described fields above for now.
I'll be very grateful for any help.
Thanks to @mrupsidown for help!
The correct way to set custom maxZoom
is to change the algorithm:
const algorithm = new SuperClusterAlgorithm({ maxZoom: 12 })
new MarkerClusterer({map, markers, algorithm, renderer, onClusterClick});
I was stuck on this as well and found an easier solution. You just need to pass an object algorithmOptions
.
new MarkerClusterer({map, markers, algorithmOptions: { maxZoom: 10 }});
I also didn't understand the docs properly but found it by looking into the source code: https://github.com/googlemaps/js-markerclusterer/blob/e3ea80c1172eedc0f9784d832f419153a49825ce/src/markerclusterer.ts#L84C8-L84C8
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With