Is there any way to determine if a feature layer can be accessed by the map before adding it?
In cases where a layer is a protected resource, I don't want it sitting in the layerlist with a warning that it is not accessable.
Solved! Go to Solution.
close @Christer , no need for whenOnce().
It ended up being along the lines of:
try {
await layer.load();
// execute rest of code
} catch (e) {
// manage exception
}
Hi, you can manually try load the layer before adding it to the map. if im not mistaken.
Sample:
import { whenOnce } from '@arcgis/core/core/reactiveUtils';
myLayer = new FeatureLayer(..)
whenOnce(() => myLayer.loaded == true).then(() => {
console.log('All good');
view.map.add(myLayer);
});
myLayer.load();
close @Christer , no need for whenOnce().
It ended up being along the lines of:
try {
await layer.load();
// execute rest of code
} catch (e) {
// manage exception
}