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);
}
})
Agree it should be just a case of if/else try/catch once the return has been resolved. However, I'm obviously not understanding the promise flow properly.
In the sample code if/else where the console.log(no data) line of code runs, it does output correctly once the .then has been resolved. However, just before that console.log runs the errors shown in the image about 'can't resolve layer view' happen.
The .catch at the end does not run so I must be structuring something else wrong..
I think I need to catch the error before the .then as it gets resolved after the .queryFeatures I'd imagine.
So can I put a .catch before the .then!!
Maybe you could query the featureCount before querying the actual data.