2011-10-26 63 views
4

我創建的地圖這樣的集羣:關閉集羣與谷歌地圖API

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

沒有「清新」的地圖標記,是有可能暫時關閉集羣,然後將其重新上?

回答

3

您可以嘗試將maxZoom和gridSize設置爲最小值。

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

在此之前,您可以保存以前的值(getMaxZoom()和getGridSize())。依靠reference沒有什麼像enableClustering()。

+1

嗨,感謝您的回答 - 我居然找到了一個很好的例子,在HTTP ....://www.geocodezip.com/v3_GoogleEx_markerclusterer_unclusterB.html –

2

repaint()方法爲我工作:

var markerCluster2 = new MarkerClusterer(map, markers, mcOptions); 

$('#turnoff_clustering').click(function(){ 
       markerCluster2.setMaxZoom(1); 
       markerCluster2.repaint(); 
}); 
+0

應該指出,在上面的例子中,MarkerClustererPlus必須用作MarkerClusterer沒有的.repaint()方法。 – danagerous