Select to view content in your preferred language

Extent-based spatial query on FeatureLayer made from featureCollectionObject

685
2
Jump to solution
01-08-2014 08:23 AM
Jay_Gregory
Frequent Contributor
I have created a FeatureLayer based on a featureCollectionObject (i.e. not from a service URL), and I would like to perform a spatial query on it.  The documentation claims that it "does not support queries that need to be performed on the server, e.g. queries with a where clause or non-extent based spatial queries."  So according to this, it should support an extent based spatial query.  However, when I construct my query:

var query = new Query(); query.geometry = pointToExtent(map, evt.mapPoint, 20);


and try to execute, I get the following error message: "FeatureLayer::selectFeatures - query contains one or more unsupported parameters."

I have tried changing the query.spatialRelationship attribute (from the default INTERECTS to CONTAINS or WITHIN) but that doesn't help.  There are no other aspects to the query - no where clause or time clause or anything other than the geometry (which I've set to an extent).  Can someone help me execute this query correctly?
0 Kudos
1 Solution

Accepted Solutions
derekswingley1
Deactivated User
Can you post a full repro case?

Edit:  here's a working example:  http://dl.dropboxusercontent.com/u/2654618/fl-from-fc/fl-from-fc-query-with-extent.html

Relevant code:
map.on("click", function(e) {   map.graphics.clear();   // create an extent   var pad = map.extent.getWidth() / 10;   var extent = new Extent(     e.mapPoint.x - pad, e.mapPoint.y - pad,      e.mapPoint.x + pad, e.mapPoint.y + pad, map.spatialReference   );   // add the extent as a graphic   map.graphics.add(new Graphic(     extent, new SimpleFillSymbol().setColor(null).outline.setColor("#fff")   ));   var q = new Query();   q.geometry = extent;   featureLayer.queryFeatures(q).then(     function(result) {       console.log("query result", result);     },     function(error) {       console.log("query error", error);     }   ); });

View solution in original post

0 Kudos
2 Replies
derekswingley1
Deactivated User
Can you post a full repro case?

Edit:  here's a working example:  http://dl.dropboxusercontent.com/u/2654618/fl-from-fc/fl-from-fc-query-with-extent.html

Relevant code:
map.on("click", function(e) {   map.graphics.clear();   // create an extent   var pad = map.extent.getWidth() / 10;   var extent = new Extent(     e.mapPoint.x - pad, e.mapPoint.y - pad,      e.mapPoint.x + pad, e.mapPoint.y + pad, map.spatialReference   );   // add the extent as a graphic   map.graphics.add(new Graphic(     extent, new SimpleFillSymbol().setColor(null).outline.setColor("#fff")   ));   var q = new Query();   q.geometry = extent;   featureLayer.queryFeatures(q).then(     function(result) {       console.log("query result", result);     },     function(error) {       console.log("query error", error);     }   ); });
0 Kudos
Jay_Gregory
Frequent Contributor
Thanks Derek - I was able to get it to work by copying the format of your example.  There were a couple differences with my code (but not much).  Following the example's layout solved the problem for me.

The next challenge is to get paging to work with the popups....
0 Kudos