GraphicLayer
约 181 字小于 1 分钟
简单示例
import Map from "@arcgis/core/Map"
import MapView from "@arcgis/core/views/MapView"
import GraphicsLayer from "@arcgis/core/layers/GraphicsLayer"
import Graphic from "@arcgis/core/Graphic"
const graphicLayer = new GraphicsLayer()
const map = new Map({
basemap: 'dark-gray',
layers: [ graphicLayer ]
})
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
}
}
})
graphicLayer.add(polygonGraphic)
相关方法:
add()
,增加一个,传一个graphic
addMany()
,增加多个,传一个graphic
数组remove()
,删除一个,传一个graphic
removeMany()
,删除多个,传一个graphic
数组removeAll()
,删除所有