是否可以在 ArcGIS 中以编程方式绘制多段线或多边形?

Is it possible in ArcGIS to draw a polyline or polygon programmatically?

如果我提供所需的几何坐标,是否可以在 ArcGIS 中以编程方式绘制折线或多边形?就像折线一样,我会为该线提供两个端点。

这在 2D/3D 中都是可能的。最简单的方法是向视图的图形添加 Graphic containing the Polyline(或任何其他几何图形):

// Coordinates of Zurich, Switzerland
var pointA = [8.5107858, 47.3922425];

// Coordinates of Kochi, India
var pointB = [76.3333005, 10.0023473];

var polyline = new Graphic({
  geometry: {
    type: "polyline",
    spatialReference: { wkid: 4326 },
    paths: [[pointA, pointB]]
  },
  symbol: {
    type: "simple-line",
    color: "orange",
    width: 4
  }
});
view.graphics.add(polyline);

下面的 CodePen 在 3D 地球上绘制了上面的折线:https://codepen.io/arnofiva/pen/7ae74bb9798a01ada6d60f3d1ee5612b

有关详细信息,请参阅以下资源: