I want to zoom on the extent of all the features contained in a list.
Firstly, I put my feature in a list:
selectedFeatures = [];
vector2.getSource().forEachFeature(function(feature) {
var att = feature.get("NOM");
if (att == strUser) {
selectedFeatures.push(feature);
}
});
Secondly, here my problem... i want to zoom on the extent of all the feature on my list "selectedFeatures"
I try this but always return me an infinite extent:
var vectorSource = new ol.source.Vector({
projection: 'EPSG:3857',
features: selectedFeatures //add an array of features
});
var dataExtent = vectorSource.getExtent();
map.getView().fitExtent(dataExtent, map.getSize())
console.log("Extents : " + dataExtent);
Someone have a solution to get the extent of features contained in a list ?
vectorSource.getExtent()
should work fine. Might there be a problem with the coordinates of your features? – Barragan