在OpenLayers中,我使用聚类策略来限制用户在地图上看到的特征/点的数量。但是,当用户完全缩放时,我希望关闭聚类策略,以便显示所有特征。为此,我通过以下方式捕获缩放事件:
map.events.register("zoomend", this, function (e) {
if (map.getZoom() === this.mapMaxZoom) {
// Don't cluster at this level. No matter what.
this.vector.strategies[0].threshold = 1000;
console.log("setting the clustering strategy to 1000");
}
});
这个方法有点用,但是我没有看到新的聚类应用 - 我必须再次缩小地图才能看到聚类变为1000(从而显示所有特征)。我需要一种强制openlayers刷新的方法。我已经尝试调用map.redraw(),但没有帮助。有什么想法吗?