I can't figure out a way to send a query to an ArcGIS rest endpoint asking for all the points which are contained within an extent. Does anyone know how to do this? Below is some code I've tried (sensitive information removed).
var extent: esri.geometry.Extent = new esri.geometry.Extent(pointMinX, pointMinY, pointMaxX, pointMaxY, point.spatialReference);
var queryTask: esri.tasks.QueryTask = new esri.tasks.QueryTask({ArcServiceURL}, null);
var query: esri.tasks.Query = new esri.tasks.Query();
query.spatialRelationship = esri.tasks.Query.SPATIAL_REL_INTERSECTS; // what to use here???
query.geometry = extent;
query.returnGeometry = true;
query.outFields = ["*"];
query.where = "1 = 1";
map.setExtent(extent); // This works. Changes to the correct extent.
The question again -- How can I send and extent in a query so that it brings back all the points contained inside that extent?
I think you just need to execute the queryTask with a callback funtion specified:
QueryTask | API Reference | ArcGIS API for JavaScript 3.17
queryTask.execute(query, doStuffWithResults);
That's not the issue Basson. It's about when queryTask.exectute(query, doStuffWithResults) is called.
It works and I need it to have a spatial query specified which will return bring back everything inside the extent variable given. I've tried all combinations and no spatial relationship operator brings back all the results specified inside the geometry specified.
Are the number of points that you expect to be returned more than the Map/Feature Service record limit e.g. 1000? You can find this at the REST endpoint information in the services directory.
Nah, it's nothing to do with that. Look at Query | API Reference | ArcGIS API for JavaScript 3.17
There^ you will see the "Constants" area with a bunch of SPATIAL_REL_XXXXX constants. I need to know if one of these will return all the points founds at the rest endpoint found inside the input geometry.
Then INTERSECT should work. Might need to recheck that extent geometry to make sure it is valid for your map and spatialreference.
INTERSECT brings back all the points which touch the edges of the extent
The reason I know the spatialreference is correct is that using "map.graphics.add(extent, symbol)" puts the extent on the map in the correct place and "map.setExtent(extent);" takes me to the correct extent. After that I can see that the points "INTERSECT"-ing the boundaries of the extent are returned.
Only inside: SPATIAL_REL_CONTAINS or SPATIAL_REL_WITHIN:
Also make sure you set the geometry precision finer to something like 0.00001 if working in a geographic coordinate system.