When featurelayer done drawing

253
1
Jump to solution
02-12-2020 08:42 AM
KevinHibma
Esri Contributor

Hi,

Can anyone give a pointer for the 4.x API that would allow me to listen for when a feature layer query is done?

My workflow allows a user to query a feature layer and draw a graphics layer based on the result of that query. Eventually the app zooms to the result. As some queries can load hundreds of complex feature, we need to put a sort of "processing" message on the app and remove it once finished. The only semi-reliable way to remove this processing message I've found is to listen for the map to stop zoom/panning to the new features. (The zoom will sometimes happen before all the features have been loaded from the query, as the query and draw are done with a promise (asynchronously)

        watchUtils.whenTrue(mapView"stationary"function() {
          const modal = document.getElementById("myModal");
          modal.style.display = "none";
        });

Is there some watchUtils for a feature layer that I've missed reading over the doc?

thanks

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
ReneRubalcava
Frequent Contributor

You want to check for the FeatureLayerView updating property to be false.

Here is how you can check for when multiple layers are done loading when the app starts.

https://codepen.io/odoe/pen/vJdVpQ?editors=0011 

  Promise.all([
view.whenLayerView(fLayer),
view.whenLayerView(fLayer2)
]).then(([layerView1, layerView2]) => {
return Promise.all(
[
whenFalseOnce(layerView1, "updating"),
whenFalseOnce(layerView2, "updating")
]
);
}).then(() => {
console.log("done updating")
});

View solution in original post

1 Reply
ReneRubalcava
Frequent Contributor

You want to check for the FeatureLayerView updating property to be false.

Here is how you can check for when multiple layers are done loading when the app starts.

https://codepen.io/odoe/pen/vJdVpQ?editors=0011 

  Promise.all([
view.whenLayerView(fLayer),
view.whenLayerView(fLayer2)
]).then(([layerView1, layerView2]) => {
return Promise.all(
[
whenFalseOnce(layerView1, "updating"),
whenFalseOnce(layerView2, "updating")
]
);
}).then(() => {
console.log("done updating")
});

View solution in original post