Select to view content in your preferred language

Select only features within a drawn polygon

2665
4
Jump to solution
03-30-2016 06:51 AM
RichardMoussopo
Frequent Contributor

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
Frequent Contributor

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
Frequent Contributor

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
Frequent Contributor

Looks like you have a typo in line 7:

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

RichardMoussopo
Frequent Contributor

Thank you Bill, Case really counts!

0 Kudos