Select to view content in your preferred language

Select only features within a drawn polygon

2623
4
Jump to solution
03-30-2016 06:51 AM
RichardMoussopo
Occasional Contributor III

I am using query task to select only features within a drawn polygon.

    executeRequestByShape: function () {
                var deffByShape = new Deferred();
                var queryTask = new QueryTask(this.layerUrl);
                var query = new Query();
                query.returnGeometry = true;
                query.geometry = this.geometry;
                query.spatialRelationShip = Query.SPATIAL_REL_WITHIN;
                query.outFields = ["*"];
                var queryResults = queryTask.execute(query);
                var promiseResult = all([queryResults])
                          .then(function (r) {
                              deffByShape.resolve(r);
                          })
                return deffByShape.promise;
            }

but this code is returning features that intersect the drawn polygon. Any idea?

1 Solution

Accepted Solutions
BillDaigle
Occasional Contributor III

Looks like you have a typo in line 7:

query.spatialRelationShip should be query.spatialRelationship.  Case counts!

View solution in original post

4 Replies
RobertScheitlin__GISP
MVP Emeritus

Richard,

  Use SPATIAL_REL_CONTAINS instead.

0 Kudos
RichardMoussopo
Occasional Contributor III

Thank you Robert for your quick reply. Changed the code to contains and the result is the same. here is what the selection looks like:

I only want the "Yes" to be selected.

contains.PNG

0 Kudos
BillDaigle
Occasional Contributor III

Looks like you have a typo in line 7:

query.spatialRelationShip should be query.spatialRelationship.  Case counts!

RichardMoussopo
Occasional Contributor III

Thank you Bill, Case really counts!

0 Kudos