画矩阵没有Rectangle,只用Polygon
代码:
// 画长方形的高亮区域 start
const [ Polygon,Graphic] = await loadModules([
"esri/geometry/Polygon",
"esri/Graphic",
]);
// 创建长方形的坐标数组
const rectangleCoordinates = [
[
[121.40641563476055, 31.166685323878824], // 左下角
[121.44761436522919, 31.166685323878824], // 右下角
[121.44761436522919, 31.176654597384555], // 右上角
[121.40641563476055, 31.176654597384555], // 左上角
[121.40641563476055, 31.166685323878824], // 关闭多边形,回到左下角
],
];
// 创建Polygon对象
const polygon = new Polygon({
rings: rectangleCoordinates,
spatialReference: { wkid: 4490 },
});
// 创建Graphic对象
const graphic_poi = new Graphic({
geometry: polygon,
symbol: {
type: "simple-fill",
color: [0, 255, 0, 0.5], // 填充颜色 绿色
outline: {
color: [0, 0, 0], // 边界颜色
width: 1,
},
},
});
const layer = this.mapView.map.findLayerById("selfSketchLayer");
layer.add(graphic_poi);
// 画长方形的高亮区域end