How to know if a feature layer has finish drawing

3499
3
03-15-2016 08:17 PM
BryanSng1
New Contributor II

Hello guys,

As per my question, what I'm trying to achieve is simply:

[Scenario #1 - Feature layer not yet added to map]

1) Add feature layer to map

2) Show loading indicator

3) Wait for features in feature layer to load finish

4) Hide loading indicator

[Scenario #2 - Feature layer previously added to map]

1) Show feature layer on map

2) Show loading indicator

3) Wait for features in feature layer to load finish

4) Hide loading indicator

I'm trying to use the "update-end" event of the feature layer to achieve both scenario.

However in situation when the feature layer cannot be drawn due to reason like:

1) graphics can only be drawn at a certain zoom extent and the current extent do not allow it

The "update-end" event will not get executed and my loading indicator "hang" because there is no event to hide the loading indicator

Do you guys have any insights or specifically any event that I can use to ensure I can receive notification after a feature layer "draw" is completed? Thanks!

P.S. I'm using arcgis javascript api

3 Replies
RobertScheitlin__GISP
MVP Emeritus

Bryan,

  For the use case that is not working for you, what you can do is check the isVisbleAtScale method and turn off your loding indicator if this is false.

FeatureLayer | API Reference | ArcGIS API for JavaScript | isVisbleAtScale

thejuskambi
Occasional Contributor III

If my understanding is correct, you are showing the load indicator in a method which is not a event. try this, Show the load indicator in update-start event and hide it in update-end event. That way when ever the feature layer is updating its content the load indicator will be shown. And incase the layer is not visible, both the events will not be fired and it will not display the load indicator.

Hope this was helpful.

BryanSng
New Contributor

Hmm, these comments does give me some insight, super thanks guys!

I will work on some solution based on your inputs!

0 Kudos