Select to view content in your preferred language

Get intersection of polygon and point graphics

1025
2
Jump to solution
05-13-2022 06:11 AM
YogeshSwami
Emerging Contributor

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?

YogeshSwami_0-1652447202422.png

 

0 Kudos
1 Solution

Accepted Solutions
JoelBennett
MVP Regular Contributor

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

 

View solution in original post

2 Replies
JoelBennett
MVP Regular Contributor

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

 

YogeshSwami
Emerging Contributor

Thank you so much @JoelBennett . It works.

0 Kudos