【发布时间】:2016-11-27 21:10:20
【问题描述】:
在 jquery 移动网络应用程序中使用 google maps v3 和 markerclusterer,工作正常。我有一个列表视图,我想在单击时填充集群中所有标记的详细信息,前提是该集群包含 25 个或更少的标记,如果有 26 个或更多的标记,我希望默认缩放操作。
我已经在 markerclusterer.js 中识别了 onclick 事件,我需要在这里放置我的代码...
/**
* Triggers the clusterclick event and zoom's if the option is set.
*
* @param {google.maps.MouseEvent} event The event to propagate
*/
ClusterIcon.prototype.triggerClusterClick = function(event) {
var markerClusterer = this.cluster_.getMarkerClusterer();
// Trigger the clusterclick event.
google.maps.event.trigger(markerClusterer, 'clusterclick', this.cluster_, event);
if (markerClusterer.isZoomOnClick()) {
// Zoom into the cluster.
this.map_.fitBounds(this.cluster_.getBounds());
}
//my code will go here...
//get number of markers in clicked cluster
//if > 25 then zoom as normal
//else get cluster's child markers and loop through to add to listview
};
...但是有没有一种简单的方法可以访问仅包含在单击的集群中的标记的数组,假设 25 个或更少的标记,如果不正常缩放。
我可以处理 Listview 更新,但不知道如何隔离任何给定集群的标记...有人可以帮忙吗?哦,我已在 markerclusterer.js 中将 zoomOnCLick 设置为 False,但也许我应该将其保持为 true 并捕获少于 26 个标记的集群以更新我的列表视图。
提前致谢。
【问题讨论】:
标签: javascript google-maps google-maps-api-3