Filter Features in Clusters
Opened this issue · 2 comments
evisms commented
I am showing a Cluster Layer and I would like to filter the features shown in the Layer by a property name. How could I integrate that filter?
Thanks in advance
juristr commented
Hi @evisms, I don't think this is possible right now, like to filter features within a layer. Could you paste a code example how you register your layer with this directive?
One possibility could be to access the native ol3 api directly and manipulate the layer's features there, once it is attached to the ol3 map via this directive.
olData.getMap().then(function(map) {
// map is the native ol3 map object, so
// all those APIs can be used
var layers = map.getLayers();
// iterate over "layers" and pick out the layer of interest
});
evisms commented
Thanks for your quick answer. The code I use is this for the controller:
```javascript
layers: [
{
visible:false,
name:'clusters',
clustering: true,
clusteringDistance: 40,
source:
{
type: 'GeoJSON',
url: GeoserverPath + '?service=WFS&version=1.0.0&request=GetFeature&typeName=spada:lte&maxFeatures=200&outputFormat=application%2Fjson',
},
style: getStyleAll
},
```
And the html code:
```html
<div id = "mapaOL">
<openlayers id="map" ol-center="spain" ol-defaults="defaults">
<ol-control name="{{control.name }}" ng-repeat="control in controls|filter:
{active: true}"></ol-control>
<ol-layer ol-layer-properties="clusters"></ol-layer>
</openlayers>
</div>
```
The function getStyleAll I took it from one of your examples, perhaps ther
would it be possible to filter? I copy the code of the function:
```javascript
function getStyleAll(feature) {
var features = feature.get('features');
var style = null;
if ( features && features.length > 1 ) {
style = createPointStyle('grey', features.length.toFixed());
} else {
var props =features[0].n;
style = createIconStyle(props.operador);
}
return [ style ];
}
```
Thanks in advance