2017-06-09 92 views
0

我用的OpenLayers 3.我有一個集羣層:的OpenLayers 3.集羣

var layer = new ol.layer.Vector({ 
    source: new ol.source.Cluster({ 
     distance: 10, 
     source: new ol.source.Vector({ 
      features: [] 
     }) 
    }) 
}); 

我添加兩個功能,這樣說:

this.feature1 = <some feature with style>; 
this.feature2 = <some feature with style>; 
layer.getSource().getSource().addFeature(this.feature1); 
layer.getSource().getSource().addFeature(this.feature2); 

然後我想隱藏我的特點theire樣式設置爲null:

this.feature1.setStyle(null); 
this.feature2.setStyle(null); 

所以,在地圖上這些功能是不可見的。但是,如果這些功能彼此靠近放置,則會顯示羣集標記。所以,我的問題是下一個:是否有任何方式不考慮聚類中的空風格的功能?

回答

0

您可以在創建Cluster源時指定「geometryFunction」參數。

此函數將被調用,並使您能夠確定應包含在羣集中的內容。

+0

我已經嘗試過,但看起來像這個參數不適用於我的OL3版本。哪個版本是可用的這樣的參數?我使用的是Openlayers 3.7.0 – Tommy