嘿,我正在为谷歌地图使用流行的 markerclusterer 插件,可以在 http://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclusterer/src/markerclusterer.js 找到它。
我想知道我可以使用什么函数来手动添加一个 clustermarker,因为当我缩小很多时,我想在通过网络发送大量 json 之前在服务器端对标记进行集群。
添加clustermarker调用什么函数?
非常感谢任何帮助
最佳答案
由于没有其他答案,我自己对 MarkerClusterer 进行了扩展,我相信它可以重写为更好的标准,但这是我能想到的:
MarkerClusterer.prototype.AddCluster = function(clat, clng, csize)
{
var clusterlocation = new google.maps.LatLng(clat, clng)
var CI = new ClusterIcon(new Cluster(this), this.getStyles, this.getGridSize());
var index = 0;
var dv = csize;
while (dv !== 0) {
dv = parseInt(dv / 10, 10);
index++;
}
var style = this.styles_[index-1];
CI.setCenter(clusterlocation);
$.extend(CI, {sums_ : {text : csize, index: index}, url_ : style['url'], width_ : style['width'], height_ : style['height']});
CI.setMap(this.map_);
CI.show();
CI.triggerClusterClick = function()
{this.map_.setCenter(clusterlocation);
this.map_.setZoom(this.map_.getZoom()+1); }
}
关于javascript - 使用 markerclusterer 为 map v3 手动绘制集群,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4811042/