Dear all,
i am facing problem to check weather my point inside the one polygon layer extent are it is outside.i draw the point from my input coordinates paramter.in the map i have another layer which is polygon.i add the point on map and i can see it is inside.but my code always retur point outside from polygon extent layer.please help.
thanks
Nadir,
What does the code look like that you are using to check if the polygon contains the point? Are the point and the Polygon Feature in the same WKID?
dear robert
my code below,
pt = new Point(txtLong, txtLat, map.spatialReference);
queryTask = new esri.tasks.QueryTask(RestServiceUrl + "/4");
query = new esri.tasks.Query();
query.geometry = pt;
// query.spatialRelationship = Query.SPATIAL_REL_INTERSECTS;
query.spatialRelationship = Query.SPATIAL_REL_WITHIN;
i check both query option.but same result.
pls help.
Hi Nadir!
Is this the complete Code? Have you check your require if it's complete?
It seems you are using the legacy-Modul, is that right?
If you check the legacy Documentation for the esri.Task.query your definition should look like this:
query.spatialRelationship = esri.Task.Query.SPATIAL_REL_WITHIN;
Maybe this will do the job.
By the way, I would recommend you to have a close look inside the documentation.
Query (legacy) | API Reference | ArcGIS API for JavaScript
Regards, Miriam
Nadir,
I think Miriam is on the right track here. You are mixing Legacy and AMD in your code and you REALLY need to get out of this habit. If you are not aware what differentiates the two then the simple way to know is if you are using "esri.tasks.QueryTask" instead of just "QueryTask" and it associated require then you are using Legacy. I do not recommend anyone continue using Legacy module as the JS API 4.0 is just about to be released and legacy will NOT be supported. Spend some time reading this blog about AMD
The abc’s of AMD | ArcGIS Blog
So assuming that you have the require for QueryTask and Query as well as their positional arguments then your code would look like this:
pt = new Point(txtLong, txtLat, map.spatialReference); queryTask = new QueryTask(RestServiceUrl + "/4"); query = new Query(); query.geometry = pt; query.spatialRelationship = Query.SPATIAL_REL_WITHIN;