刚开始接触arcgis for js 不久,画个矩形都折腾半天,现在汇总一下,方便以后使用,也算是总结一下
const graLayer = new GraphicsLayer();
//设置线的样式
const symbol = new SimpleFillSymbol().setColor(null).outline.setColor("#53dcfd");
//创建线对象
const polygon = new Polygon(new SpatialReference({ wkid: 4326 }));
var point = [
[
112.00000000020009,
21.000000000399893
], [
112.00000000020009,
20.499999999600448
], [
112.50000000010016,
20.499999999600448
], [
113.00000000000034,
20.499999999600448
], [
113.49999999990041,
20.499999999600448
], [
113.99999999980048,
20.499999999600448
], [
114.49999999970055,
20.499999999600448
], [
114.49999999970055,
19.999999999700378
],
]
polygon.addRing(point);
var graphic = new Graphic(polygon, symbol);
graLayer.add(graphic);
map.addLayer(graLayer);
//添加多边形的各个角的顶点坐标,注意:首尾要链接,也就是说,第一个点和最后一个点要一致
绘制文字
var point = new Point([114.49999999970055, 19.999999999700378]);
var textSym = new TextSymbol("hello world");
var font = new Font();
font.setSize("14pt");
font.setWeight(Font.WEIGHT_BOLD);
textSym.setFont(font);
textSym.setColor(new Color([255, 0, 0, 0.8]));
var labelPointGraphic = new Graphic(point, textSym);
graLayer.add(labelPointGraphic)
map.addLayer(graLayer)