Long background in Openlayers but taking on the Experience Builder Widget development challenge and so far okay. However can't fathom how to access a layers data after its added to the map. Could someone point me to a tutorial or resource on what I thought I could easily where I want to generate a UI element containing some of the layer attribute data after it loads. So I need to get the data and loop through it. I can get the data fine and display it on the map but can't seem to access it through the layer, view or layerView objects.
Code currently using to get the data is as follows:
const layer = new this.GeoJSONLayer({
url: requestURL,
customParameters: {
request: this.state.bbox,
},
title: "New data",
renderer: {
type: "simple",
symbol: {
type: "simple-line",
width: 2,
Color: "blue"
}
}
});
JimuMapView.view.map.add(layer);
// After the layer is created try to build UI element from layer data.
layer.on('layerview-create', (event) => {
try{
const results = event.layerView.queryFeatures();
const graphics = results.features;
console.log(graphics); //Just returns null
}catch (error){
console.error("query failed: ", error);
}
})