Select to view content in your preferred language

problem with FeatureLayer.queryFeatures() the query parameter looks to be ignored

3966
2
Jump to solution
05-30-2012 02:49 AM
JeroenWisse
Emerging Contributor
Hi All,

I have a problem with the queryFeatures() method of the featureLayer.
First of all i am using flex api 2.5

The relevant code is:

            var points:Array = [];             var tol:Number = Settings.Instance.Tolerance * mainMap.extent.width / mainMap.width / 2;             var x:Number = event.mapPoint.x;             var y:Number = event.mapPoint.y;              var numPoints:int = 25;             for (var i:int = 0; i < numPoints + 1; i++) // Add 1 extra point (last should equal first)             {                 var p:MapPoint = new MapPoint(x - tol * (Math.sin(i / numPoints * 2 * Math.PI)), y + tol * Math.cos(i / numPoints * 2 * Math.PI), mainMap.spatialReference);                 points.push(p);             }              var q:Query = new Query();             q.geometry = new Polygon([ points ], mainMap.spatialReference);             q.returnGeometry = false;             q.outFields = [ fl.layerDetails.objectIdField];              var fl:FeatureLayer = Utils.featureLayerByName(mainMap, layerDef.layerName);//it's not null so it can find the featureLayer             fl.addEventListener(FeatureLayerEvent.QUERY_FEATURES_COMPLETE, featureLayerQueryComplete);             fl.queryFeatures(q, null);


The query works and i get the results i need but the problem is that the outfield and return geometry is ignored.
So i get back all the fields from the query and it always gives back the geometry.

The request that is being sent is:

/ArcGIS/rest/services/chs/MapServer/35/query?f=json&geometryType=esriGeometryPolygon&outFields=*&geometry={%22rings%22%3A[[[41347.737278807894%2C397740.771314876]%2C[41314.83761335238%2C397736.61512058787]%2C[41284.00515487394%2C397724.40768669615]%2C[41257.177220132624%2C397704.91605116805]%2C[41236.03950693448%2C397679.364945149]%2C[41221.920175538806%2C397649.35983860056]%2C[41215.70639546447%2C397616.7860627182]%2C[41217.78860136622%2C397583.6903476386]%2C[41228.03596058944%2C397552.15221885784]%2C[41245.804593866975%2C397524.1533329962]%2C[41269.97803262154%2C397501.4529630251]%2C[41299.0373707925%2C397485.47745667596]%2C[41331.156703289795%2C397477.23061376653]%2C[41364.31785432599%2C397477.23061376653]%2C[41396.437186823285%2C397485.47745667596]%2C[41425.49652499425%2C397501.4529630251]%2C[41449.66996374881%2C397524.1533329962]%2C[41467.43859702635%2C397552.15221885784]%2C[41477.68595624957%2C397583.6903476386]%2C[41479.76816215132%2C397616.7860627182]%2C[41473.55438207698%2C397649.35983860056]%2C[41459.435050681306%2C397679.364945149]%2C[41438.29733748316%2C397704.91605116805]%2C[41411.469402741845%2C397724.40768669615]%2C[41380.63694426341%2C397736.61512058787]%2C[41347.737278807894%2C397740.771314876]]]}&returnGeometry=true&inSR=28992&spatialRel=esriSpatialRelIntersects&outSR=28992

The return of that request is:

{"displayFieldName":"ODB_NR","fieldAliases":{"ODB_NR":"ODB_NR","OBJECTID":"OBJECTID","NR":"NR","CODE":"CODE","COMPLEX":"COMPLEX","GEMEENTE":"GEMEENTE","PLAATS":"PLAATS","STRAAT":"STRAAT","POSTCODE":"POSTCODE","HUISNR":"HUISNR","TOEV":"TOEV","SITUERING":"SITUERING","LOCATIE":"LOCATIE","BEBKOM":"BEBKOM","NAAM":"NAAM","MSP":"MSP","WETSART":"WETSART","BOUWJAARVAN":"BOUWJAAR VAN","BOUWJAARTOT":"BOUWJAAR TOT","VERVALDAT":"VERVALDATUM","KERNDATUM":"KERNDATUM","PERIODEVAN":"PERIODE VAN","PERIODETOT":"PERIODE TOT","STATUS":"STATUS","COMPLEXID":"COMPLEXID","REPORTLINK":"REPORTLINK"},"geometryType":"esriGeometryPoint","spatialReference":{"wkid":28992},"features":[{"attributes":{"ODB_NR":"39103","OBJECTID":10619,"NR":39103,"CODE":"4493PE-00018-01","COMPLEX":"NEE","GEMEENTE":"NOORD-BEVELAND","PLAATS":"GEERSDIJK","STRAAT":"STEKELDIJK","POSTCODE":"4493PE","HUISNR":18,"TOEV" : null,"SITUERING" : null,"LOCATIE" : null,"BEBKOM" : null,"NAAM":"*","MSP":"Nee","WETSART":"Rijksmonument, Art.6/Ingeschreven","BOUWJAARVAN" : null,"BOUWJAARTOT" : null,"VERVALDAT" : null,"KERNDATUM" : null,"PERIODEVAN" : null,"PERIODETOT" : null,"STATUS":"PUBLIEK","COMPLEXID" : null,"REPORTLINK":"/reports/rwservlet?module=CHSMON50TPL.RDF+destype=cache+desformat=pdf+cmdkey=chsmon+RAPID=0+MONSOORT=RIJKSMON+MONNR=39103"},"geometry":{"x":41309,"y":397595}}]}

As you can see the result is that all fields are being returned.

Any ideas what i am doing wrong?
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
IvanBespalov
Frequent Contributor
The request that is being sent is: 

/ArcGIS/rest/services/chs/MapServer/35/query?f=json&geometryType=esriGeometryPolygon&  outFields=*&geometry={...}&  returnGeometry=true&inSR=28992&spatialRel=esriSpatialRelIntersects&outSR=28992


As i see

  • outFields=* - all fields

  • returnGeometry=true

from API reference for queryFeatures() method
Query features from the feature layer. Current layer properties (layer definition, time definition) will be honored and passed into the query.


as i understand, layer definition = all layer params you set (mode, out fields ...)
if you query through layer (not through QueryTask) you returnGeometry=false is ingored

you need in ID's only?
you can use queryIds() method - returns only objectIdField values

View solution in original post

0 Kudos
2 Replies
IvanBespalov
Frequent Contributor
The request that is being sent is: 

/ArcGIS/rest/services/chs/MapServer/35/query?f=json&geometryType=esriGeometryPolygon&  outFields=*&geometry={...}&  returnGeometry=true&inSR=28992&spatialRel=esriSpatialRelIntersects&outSR=28992


As i see

  • outFields=* - all fields

  • returnGeometry=true

from API reference for queryFeatures() method
Query features from the feature layer. Current layer properties (layer definition, time definition) will be honored and passed into the query.


as i understand, layer definition = all layer params you set (mode, out fields ...)
if you query through layer (not through QueryTask) you returnGeometry=false is ingored

you need in ID's only?
you can use queryIds() method - returns only objectIdField values
0 Kudos
JeroenWisse
Emerging Contributor
Thanks for your help.

I have it fixed now by setting the display fields of the featureLayer in stead of the query.

I know i can use the queryIDs() function if i only need the objectid's but i need more.
Anyway it works now thanks again
0 Kudos