Hi, I'm new to the JavaScript API and am trying to use client side layerviews. If I am working with multiple feature layers and want to make sure all of them are ready to use, is there an alternative to this nested ugliness?
view.whenLayerView(myFirstLayer).then(function (myFirstLayerView) {
view.whenLayerView(mySecondLayer).then(function (mySecondLayerView) {
view.whenLayerView(myThirdLayer).then(function (myThirdLayerView) {
// now that I know all my layer views are ready I can do things with them
})
})
})
I did see the following and was thinking it would be clearer to just to do this 3 times
var layerView = await view.whenLayerView(layer);
but got an error message that said "await is only valid in async functions and the top level bodies of modules". I saw the following at the top but don't really understand when I have to use it since most samples don't use it.
require([...], function (...) {
(async () => {
Any help would be appreciated.
Thanks!
Solved! Go to Solution.
Here's a solution from @ReneRubalcava