Hello Community, I am trying to get the intersection point of a rectangle sketch and points from another graphics layer. How can I get the graphic points which are selected by this rectangle?
Solved! Go to Solution.
Assuming you already have a reference to the GraphicsLayer (graphicsLayer) and the rectangle (geometry) assumed to be a Polygon:
var intersectingFeatures = [];
var extent = geometry.extent;
graphicsLayer.graphics.forEach(function(graphic) {
if (extent.intersects(graphic.geometry))
intersectingFeatures.push(graphic);
});
//now do whatever with the intersectingFeatures array
Assuming you already have a reference to the GraphicsLayer (graphicsLayer) and the rectangle (geometry) assumed to be a Polygon:
var intersectingFeatures = [];
var extent = geometry.extent;
graphicsLayer.graphics.forEach(function(graphic) {
if (extent.intersects(graphic.geometry))
intersectingFeatures.push(graphic);
});
//now do whatever with the intersectingFeatures array
Thank you so much @JoelBennett . It works.