我通过以下方式从多边形中检索了点列表;
public Graphic Graphic { get; set; }
public List<MapPoint> MapPoint { get; set; }
MapPoint = new List<MapPoint>();
ESRI.ArcGIS.Client.Geometry.PointCollection points = null;
if (Graphic.Geometry is Polygon)
{
points = ((Polygon)Graphic.Geometry).Rings[0];
foreach (MapPoint mapPoint in points)
{
//Save the points
MapPoint.Add(mapPoint);
}
}
现在我的用例需要在对 List() 的属性进行序列化/反序列化之后将此几何图形附加回图形。由于环是多边形的一部分,并且多边形有一个接受地图点列表的构造函数,我猜下面的代码可以工作,但它不能编译。
如何将戒指重新放入 Graphic 属性?
List<MapPoint> mapPoint = null;
Polygon myPolygon = null;
foreach(Atribution at in sc. Atribution)
{
foreach(AtributionContour atContour in at.Contours)
{
myPolygon = new Polygon(new List<MapPoint>( AtributionContour.MapPoint.ToList()));
//Append polygon to a Geometry
//Append geometry to graphic
}
}
错误
错误 CS1729 'Polygon' 不包含采用 1 个参数的构造函数