QueryFeatures does not populate all attributes

712
5
12-06-2011 05:38 AM
BerendVeldkamp
Occasional Contributor II
Hi,
I can't seem to get FeatureLayer.queryFeatures() working... Here' s my code (stripped down to the essentials):

var q:Query=new Query();
q.geometry=new Polygon([points], mainMap.spatialReference); // this is a small buffer around a clicked point
q.returnGeometry=false;

var fl:FeatureLayer=GetMyFeatureLayer();
fl.outFields=["*"]
fl.useAMF=false;
fl.addEventListener(FeatureLayerEvent.QUERY_FEATURES_COMPLETE, featureLayerQueryComplete);
fl.queryFeatures(q, null);
When the query is executed I use Firebug to examine the actual request. This tells me that


  1. Outfields is set correctly, also if I specify a subsets of fields, e.g. ["field1", "field2"]

  2. returnGeometry is always set to true, even if I set it to false

  3. All requested field values are returned

When I examine the result values in the featureLayerQueryComplete event handler, only the objectid and the display field attributes are set.
private function featureLayerQueryComplete(event:FeatureLayerEvent):void
{
    var feature:Graphic=event.featureSet.features[0];

Why can't I set returnGeometry to false?
Why are some fields not populated?
Tags (2)
0 Kudos
5 Replies
BerendVeldkamp
Occasional Contributor II
I have some more information:

Before adding the FeatureLayer to the map, I set it's outFields to ["*"]. Now queryFeatures() populates all attributes properly, at least the ones that I set in the Query's outFields.

The only question remaining is why the geometry is returned, even though query.returnGeometry is set to false.
0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor
Berend,

   The fact that the geometry is returned when the return fields is set to * has been addressed in ArcGIS Server 10. You will have to deal with this undesired behavior until you upgrade your server.
0 Kudos
BerendVeldkamp
Occasional Contributor II
Thanks, that's good to know.
0 Kudos
DasaPaddock
Esri Regular Contributor
FeatureLayer.queryFeatures() always returns geometry since it tries to return the features it has already loaded if they satisfy the query and they will have geometries so that can be shown on the map.
0 Kudos
BerendVeldkamp
Occasional Contributor II
So it seems.

Still, if I explicitly set returnGeometry = false I'd expect no geometries to be returned.
0 Kudos