Is there an API available for determining if a point lies inside a polygon geometry determined by a ring?
To do so for a rectangle is simple, but for a ring of points which determines a polygon, what is the best way?
Thanks.
Hi Edward,
You could create a Polygon from the points XY coordinates, and then use the Polygon to determine if it contains the point.
Randy's approach of using geometry.contains is a great one. Here's another option that uses the Geometry Service.
Point in polygon search | ArcGIS API for JavaScript
I use this to see in my app if a point is in City Limits (a polygon)
yakimaCL = new esri.layers.FeatureLayer("http://gis.yakimawa.gov/arcgis101/rest/services/General/YakimaLayers/MapServer/9", { mode: esri.layers.FeatureLayer.MODE_SNAPSHOT, outFields: ["*"], opacity: .4 });//the pointvar pt = esri.geometry.geographicToWebMercator(new esri.geometry.Point(candidate.location.x.toFixed(6),candidate.location.y.toFixed(6))); // Check to see if the point is in the City Limits var isYakima = yakimaCL.graphics[0].geometry.contains(pt);
yakimaCL = new esri.layers.FeatureLayer("http://gis.yakimawa.gov/arcgis101/rest/services/General/YakimaLayers/MapServer/9", {
mode: esri.layers.FeatureLayer.MODE_SNAPSHOT,
outFields: ["*"],
opacity: .4
});
//the point
var pt = esri.geometry.geographicToWebMercator(new esri.geometry.Point(candidate.location.x.toFixed(6),candidate.location.y.toFixed(6)));
// Check to see if the point is in the City Limits
var isYakima = yakimaCL.graphics[0].geometry.contains(pt);
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.