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?
Solved! Go to Solution.
Looks like you have a typo in line 7:
query.spatialRelationShip should be query.spatialRelationship. Case counts!
Richard,
Use SPATIAL_REL_CONTAINS instead.
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.
Looks like you have a typo in line 7:
query.spatialRelationShip should be query.spatialRelationship. Case counts!
Thank you Bill, Case really counts!