它看起来没有任何内置功能,但有些事情可以使您的操作更轻松。
我会建议存储上的标记,方便来回切换集群:
myClusterer = new MarkerClusterer(map, markers);
...
google.maps.event.addListener(marker, 'click', function() {
// if marker is detached from clusterer
if(marker.clusterer) {
clusterer.attachMarkers([marker]);
marker.clusterer = null;
// if marker is attached to clusterer
} else {
marker.clusterer = myClusterer;
clusterer.removeMarker(marker);
}
});
OR事件更好,有标记店从一开始聚类器:
myClusterer = new MarkerClusterer(map)
marker = new MyClusterableMarker();
marker.attachToClusterer(myClusterer)
...
google.maps.event.addListener(marker, 'click', function() {
marker.toggleAttachmentToClusterer();
});
...
$.extend(MyClusterableMarker.prototype, google.maps.Marker.prototype, {
attachToClusterer: function(clusterer) {
this.clusterer = clusterer;
this.clusterer.attachMarkers([this]);
this.attachedToClusterer = true;
},
toggleAttachmentToClusterer: function() {
if(this.attachedToClusterer) {
this.clusterer.removeMarker(this);
this.attachedToClusterer = false;
} else {
this.clusterer.addMarkers([this]);
this.attachedToClusterer = true;
}
}
})
谢谢你,这是非常有帮助的。 – jeff 2012-08-07 17:48:05