Disabling clustering using the Google Maps API

I create clusters on the map as follows:

markerCluster = new MarkerClusterer(map, markers, mcOptions); 

Without updating map markers, is it possible to temporarily disable clustering and then turn it back on?

+4
source share
2 answers

You can try setting maxZoom and gridSize to something minimal.

 markerClusterer.setMaxZoom(1); markerClusterer.setGridSize(1); markerClusterer.redraw(); 

Before that, you can simply save the previous values โ€‹โ€‹(getMaxZoom () and getGridSize ()). Based on reference , there is nothing like enableClustering ().

+3
source

This repaint() method worked for me:

  var markerCluster2 = new MarkerClusterer(map, markers, mcOptions); $('#turnoff_clustering').click(function(){ markerCluster2.setMaxZoom(1); markerCluster2.repaint(); }); 
+2
source

All Articles