Search code examples
javascriptgoogle-maps-markersmarkerclusterer

@googlemaps/markerclusterer: How to set maxZoom?


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.


Solution

  • 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