I'm using OpenLayers 7.5.2 to create a simple map with one vector layer having two points. This works. I want to then access the layer object in the map and get to the point features to update their text attributes. However, I get "Uncaught TypeError: l.getSource is not a function" in the browser when I attempt to access the style objects, starting with getSource():
let lyrs = map_obj.getAllLayers(); //works
for (let l in lyrs) {
source = l.getSource(); //doesn't work
features = source.getFeaturesCollection(); //??
for (let f in features) {
alert('a feature');
}
}
Per the ol documentation, the getSource method belongs to the layer object. This seems straight-forward so I'm at a loss. I'm new to OpenLayers.
Here's my test page for reference.
Can you give me any pointers?
lyrs[l].getSource()
would work as it treats the array index as an object key.