多边形 - Polygon
约 170 字小于 1 分钟
多边形 - Polygon
简单示例
import Map from "@arcgis/core/Map"
import MapView from "@arcgis/core/views/MapView"
import Graphic from "@arcgis/core/Graphic"
const map = new Map({
basemap: 'dark-gray',
})
const mapView = new MapView({
map,
container: 'js_map',
center: [102.92934063304513, 25.102234987110343]
})
const polygonGraphic = new Graphic({
geometry: {
type: "polygon",
rings: [
[ // 第1个 ring
[-97.06138,32.837,35.1,4.8],
[-97.06133,32.836,35.2,4.1],
[-97.06124,32.834,35.3,4.2],
[-97.06138,32.837,35.1,4.8] // 和起点一样
], [ // 第2个 ring
[-97.06326,32.759,35.4],
[-97.06298,32.755,35.5],
[-97.06153,32.749,35.6],
[-97.06326,32.759,35.4] // 和起点一样
]
]
},
symbol: {
type: "simple-fill",
color: [227, 139, 79, 0.8],
outline: {
color: [255, 255, 255],
width: 1
}
}
})
mapView.graphics.add(polygonGraphic)
更新 geometry
polygonGraphic.geometry = {
type: "polygon",
rings: [
[
[-97.06138,32.837,35.1,4.8],
[-97.06133,32.836,35.2,4.1],
[-97.06124,32.834,35.3,4.2],
[-97.06138,32.837,35.1,4.8]
]
]
}
更新 symbol
polygonGraphic.symbol = {
type: "simple-fill",
color: [227, 139, 79, 0.8],
outline: {
color: [255, 255, 255],
width: 1
}
}