I am creating clusters on the map like this:
markerCluster = new MarkerClusterer(map, markers, mcOptions);
Without 'refreshing' the map markers, is it possible to temporarily turn off clustering and then turn it back on again?
Removing all markers You can then clear all the markers using clearMarkers something like this: markerClusterer. clearMarkers(); markers = [];
The number on a cluster indicates how many markers it contains. Notice that as you zoom into any of the cluster locations, the number on the cluster decreases, and you begin to see the individual markers on the map. Zooming out of the map consolidates the markers into clusters again.
Disable an APIGo to the API Console. From the projects list, select a project or create a new one. If the API Manager page isn't already open, open the console left side menu and select API Manager. Next to the API you want to disable, click Disable.
Easily create your styleThe new Google Maps APIs Styling Wizard helps you to create a map style in a few clicks. Use one of our pre-built styles or create your own style from scratch.
You can try to set maxZoom and gridSize to something minimal.
markerClusterer.setMaxZoom(1);
markerClusterer.setGridSize(1);
markerClusterer.redraw();
Before doing that you may just save previous values (getMaxZoom() and getGridSize()). Relying on reference there are nothing like enableClustering().
This repaint()
method worked for me:
var markerCluster2 = new MarkerClusterer(map, markers, mcOptions);
$('#turnoff_clustering').click(function(){
markerCluster2.setMaxZoom(1);
markerCluster2.repaint();
});
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