Feature response from MapView.identifyLayer vs FeatureLayer.selectFeaturesWithQuery vs FeatureTable.queryFeatures

687
2
11-29-2016 08:34 AM
JonathonGrivas
New Contributor III

MapView.identifyLayer seems to work well, it fires off a single request and returns a Feature object which has all the feature's fields and attributes. That feature comes from an instance of FeatureTable that I never created directly and prior to this query had no reference to, so I'm a bit weary to trust it. 

FeatureLayer.selectFeaturesWithQuery is used in the feature attribute update example.  This sent me down a very confusing path as I didn't realize that waiting for the feature to "load" after you've already waited for the feature response was necessary.  I now see this in the example, but I was originally working from the documentation which doesn't say anything about this. Feature is a loadable, but it's not mentioned that while the feature object and its properties/methods are usable before loading, that the feature's attributes aren't all available until after loading.  The peculiar part about this is that it results in having to wait for two chained requests in order to accomplish what a single request would have accomplished, thus making a non-loadable version actually faster.

FeatureTable.queryFeatures seems to work the exact same as selectFeaturesWithQuery, only you obviously have to select the feature yourself if you want it selected. 

I noticed that I can actually just use MapView.identifyLayer's result as my feature object, even though it comes from an unknown FeatureTable. This results in only a single request being fired off, but literally the exact same response as doing the triple-request chain that occurs in the example. 

My questions:

  1. Where does MapView.identifyLayer get its FeatureTable instance? It's different than the one I created. 
  2. Can I update a feature in my own FeatureTable instance with the feature from MapView.identifyLayer? I've tried this and it seems to work for feature attributes, but I'm having difficulty with attachments.
  3. Is there a way to get a feature's full data in a single request AND be able to edit it? It seems unreasonable to require 3 or even 2 requests for the same data to accomplish this.

I confirmed this can be seen in the feature attribute update example if you monitor http requests.  The initial click triggers two requests, and hitting update triggers another. All 3 requests query for the same feature. 

0 Kudos
2 Replies
LucasDanzinger
Esri Frequent Contributor
Where does MapView.identifyLayer get its FeatureTable instance? It's different than the one I created. 
  • This looks like a bug. We are creating a copy of the pointer behind the scenes. However, it is still completely safe to use, because it points to the same underlying table. Please submit a support ticket so that they can log a bug in the system for this.
Can I update a feature in my own FeatureTable instance with the feature from MapView.identifyLayer?
  • Yes, even though it is a copy, it points to the same underlying instance, so it is totally fine. Any other issues you see are either coding errors or different issues.
Is there a way to get a feature's full data in a single request AND be able to edit it
  • If you use identify(), the features you get back will have the bare minimum information that the geoelement needs to display. For example, this would include the ObjectID, display field name, and if applicable, whatever fields are needed for the renderer or labeling info. Everything else will be stripped. This was done for efficiency, as you could identify an area on a map view that has thousands of features. This means that if you use identify, you then need to load them once you want more information.
  • As for query, this will also return unloaded features, unless you specify the enum to have them returned loaded. The feature table should cache whatever info it has already received. So in the case of the query features sample, it has already requested unloaded features for display. It then querys the features, but does not request loaded features to be returned, so it actually does not need to send a request out. I do notice that an extra request goes out, but that is because the extent changes (and we discussed in another thread how this is likely a bug with the feature table caching). If you have any outstanding questions with how this works, let me know. 
0 Kudos
JonathonGrivas
New Contributor III

Thank you Lucas, good to know that it's the same instance of FeatureTable.

As for identify, when you say "identify()"  do you mean any of the MapView.identifyLayer.. and MapView.identifyGraphics..  methods?   I've tried identifyLayer() and identifyLayerWithMaxResults()  and both of these are sending queries to the server with outFields=*, resulting in the full sized response containing all fields and all attributes.  This can be seen in the attribute editing qml example. If you comment out "featureLayer.selectFeaturesWithQuery(params, Enums.SelectionModeNew);" then clicking on features just calls the identify method and you'll see it actually returns the full result.  Is that the expected behavior?

0 Kudos