Create polygon that holds a series of points

2088
10
Jump to solution
03-04-2021 08:31 PM
FrankLaFone
New Contributor

I'm trying to create a polygon that shows the extent of a series of points.  I have a series of addresses and can get back the centroids for the points.  All I really want is a polygon that represents the area of those points (technically plus a small buffer).  Then I want to add that polygon to the view, but not add the points.  I can add the points ok and the constructed polygon looks ok as far as it's object properties, but it just won't show up on the view.  Anyone have any ideas what I'm doing wrong here? (code below)

var points = [];
for(let i=0;i<results.features.length;i++){
points.push(results.features[i].geometry.centroid);
}

var polylineSymbol = {
type: "simple-line", // autocasts as SimpleLineSymbol()
color: [226, 119, 40],
width: 4
};
var areaPolygon = new Polygon();
areaPolygon.addRing(points);

var polylineGraphic = new Graphic({
geometry: areaPolygon,
symbol: polylineSymbol,
});
App.policyView.graphics.add(polylineGraphic);

0 Kudos
10 Replies
FrankLaFone
New Contributor

That did it!  Although... I now know "Convex Hull" isn't what I want.  But at least graphics are showing up again.  I don't know why it works with points but not polygons but... eh, I'm not going to lose too much sleep over it.  Thanks for the help!

0 Kudos