I have a layer containing a set of points and another layer with polygons. I have queried the points in a single polygon with no problems. Now I want to query these points with multiple polygon selection; i.e. the user clicks on the polygons which he wants to query and then selects the functionality to query these polygons. Currently, I am doing this procedure as the user clicks the polygons and array is populated with the geometries of the polygons and I looping through this array and query with the geometries.
for (var ai = 0; ai < multiplePolygons.length; ai++) {
var query = new Query();
var queryTask = new QueryTask(pointUrl);
query.geometry = multiplePolygons[ai].areaGeometry;
query.returnGeometry = true;
query.outFields = ["*"];
queryTask.execute(query, function (results) {
for (var i = 0; i < results.features.length; i++) {
var qResult = results.features.attributes["Attribute"];
}
});
}
Is there a more conventional way in order to query multiple polygons?