I'm in a position where i have something working with the JavaScript API and now i'm trying to replicate it with the online Query Builder tool!
Here's my QueryTask which is successfully finding the point inside a polygon:
var residualWasteRequest = function(response, textStatus, xhr)
{
var residualWasteRest = "https://myserver.com/external/rest/services/Map_Services/MapServer/0";
var query = new Query();
var queryTask = new QueryTask(residualWasteRest);
query.outSpatialReference = { wkid: 102100 };
query.where = "1=1";
query.outFields = ["*"];
query.returnGeometry = true;
queryTask.execute(query, qtResponse);
}
function qtResponse(results) {
var x = -488287.0574008291;
var y = 7519911.928379749;
var point = new Point(x, y, new SpatialReference({ wkid: 102100 }) );
for (var item in results.features) {
var polygon = results.features[item].geometry;
if (polygon.contains(point)){
console.log("point is inside a polygon: " +
results.features[item].attributes.OBJECTID);
map.centerAndZoom(point, 17);
}
}
}
Result:
point is inside a polygon: 18
Here's my equivalent query with the online tool:
I'm getting No records found.
What am i doing wrong?
thanks
Solved! Go to Solution.
Scott,
Change Spatial Relationship to intersects.
Hi Robert, changing Spacial Relationship to Intersects works a treat, thanks for your help