Why isn't layerView.watch("updating") firing as expected?

1078
6
06-20-2018 09:31 AM
JackFairfield
Occasional Contributor II

In the esri js version 4.7, the feature layerview's watch method doesn't seem to be working as expected.  This worked fine in the 4.6 version.

Consider the following example:

Simple LayerView Example

In this example, I am simply adding a feature layer and trying to watch the updating property.  If you check the console logs and zoom in / change the extent, the console log never gets called.  There is different behavior if you change the version of the js api referenced to 4.6.

It seems to be a fairly significant bug to me.

layerview‌

0 Kudos
6 Replies
RobertScheitlin__GISP
MVP Esteemed Contributor

Jack,

   I agree it does look like a bug. You need to report this to esri tech support. Until they fix this you can watch the view "updating" as a workaround.

0 Kudos
ReneRubalcava
Frequent Contributor

nvm, let me double check

0 Kudos
ReneRubalcava
Frequent Contributor

My first instincts were correct.

The FeatureLayerView "updating" property is only related to the fetching of data, not what is drawn as you pan the map around.

FeatureLayerView | API Reference | ArcGIS API for JavaScript 4.7 

This is how it should be working, the old behavior was unintended.

Depending on what you want to do, you might want to use the "stationary" property of the View.

MapView | API Reference | ArcGIS API for JavaScript 4.7 

Or maybe "interacting" to know when you are moving and panning the map around.

MapView | API Reference | ArcGIS API for JavaScript 4.7 

Thanks!

0 Kudos
JackFairfield
Occasional Contributor II

Hmm.  Then why does this esri sample (referencing 4.7) https://developers.arcgis.com/javascript/latest/sample-code/sandbox/index.html?sample=featurelayervi...

work the way I was expecting?  That sample seems to be watching the FeatureLayerView's updating property and it seems to fire when panning / zooming around the map.

Thanks for responding.

0 Kudos
ReneRubalcava
Frequent Contributor

Ah, ok. That's a little different.

That sample has WebGL enabled for the FeatureLayer, which behaves differently. When WebGL is enabled, we fetch the features in tiles and not up front.

The reason it's not up front is so that we can draw much more features in WebGL than we with regular SVG.

The "updating" is still related to the fetch of data. Sorry, should have been clear with that earlier. If you disable WebGL in that sample, the query fails, but you'll notice that the "updating" property doesn't change either.

JackFairfield
Occasional Contributor II

Ok, that makes sense.  Thanks so much for looking into this.  I still think I liked the 4.6 behavior, but at least I understand that it is related to the data retrieval being done in the layer.  That is helpful.  Thanks.

Also, it would have been nice for this breaking change to be listed in the release notes:

Release notes for 4.7 | ArcGIS API for JavaScript 4.7 

0 Kudos