在OpenLayers中,我有一個集羣策略來限制用戶在地圖上看到的特徵/點數。但是,當用戶完全放大時,我想關閉聚類策略,以顯示所有功能。要做到這一點,我趕上變焦事件是這樣的: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(),但這沒有幫助。有任何想法嗎?
請參閱[this](http://stackoverflow.com/questions/6457437/openlayers-cluster-recalculate/20050360#20050360)爲簡短方法的答案。 – Asad 2013-11-18 14:40:09