问题
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