So I retrieve all my features from a vectorTile layer (PBF from Geoserver), and now I want to recreate a layer by filtering on those features and getting only those that satisfy a request. I successfully stored my filtered features in an array, but when I try to add them to a new vector source, I get the error: typeError e is null.
See my code below:
var filteredFeatures= [];
for (var i = 0; i < data1.length; i++) {
for (var j = 0; j < features.length; j++) {
if (features[j].get(data1[i].type) == data1[i].valeur) {
filteredFeatures.push(features[j]);
}
}
var source = new ol.source.Vector({
features: filteredFeatures,
projection: proj2154,
});
map.addLayer(new ol.layer.Vector({
source:source,
style:styles.red
}));
filteredFeatures = [];
}