0

My code is very simple. This is my vector-source and this is how I render my geojson :

var vectorSource = new ol.source.Vector({
   format: new ol.format.GeoJSON(),
   url: 'some_geojson_is_here'
});

Then I pass this vectorSource as a source to a vector layer etc etc. Now I'm wondering is there any way I can get every feature this geojson has??

In this link : https://openlayers.org/en/latest/apidoc/ol.format.GeoJSON.html the 3-rd method it's what I think the way to get all features but I couldn't figure out how to use it.

Any ideas?

0

You can get the features from the vectorSource with the function getFeatures().

var vectorSource = new ol.source.Vector({
   format: new ol.format.GeoJSON(),
   url: 'some_geojson_is_here'
});

var vectorFeatures = vectorSource.getFeatures();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.