在ArcGIS中能否以编程方式绘制折线或多边形? [英] Is it possible in ArcGIS to draw a polyline or polygon programmatically?
问题描述
如果我提供了几何所需的坐标,在ArcGIS中是否可以通过编程方式绘制折线或多边形?就像折线一样,我将为折线提供两个端点.
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.
推荐答案
在2D/3D中这都是可能的.最简单的方法是添加 Graphic
Polyline
(或任何其他几何图形)到视图的图形:
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);
以下CodePen在3D地球上绘制了上述折线: https://codepen.io/arnofiva/pen/7ae74bb9798a01ada6d60f3d1ee5612b
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
这篇关于在ArcGIS中能否以编程方式绘制折线或多边形?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!