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

社会主义新天地 提交于 2019-12-24 06:37:21

问题


Is it possible in ArcGIS to draw a polyline or polygon programmatically if I provide the required coordinates for the geometry? Like for a polyline, I would be providing two endpoints for the line.


回答1:


This is possible in both 2D/3D. The simplest way is adding a Graphic containing the Polyline (or any other geometry) to the view's graphics:

// 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);

The following CodePen draws the above polyline on a 3D globe: https://codepen.io/arnofiva/pen/7ae74bb9798a01ada6d60f3d1ee5612b

See the following resources for more information:

  • Intro into Graphics
  • Add Graphics to a SceneView
  • Sketch in 3D


来源:https://stackoverflow.com/questions/57389897/is-it-possible-in-arcgis-to-draw-a-polyline-or-polygon-programmatically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!