废话不多说,直接上代码
// 需要引入SketchViewModel
let sketchLayer = new GraphicsLayer()
let bufferLayer = new GraphicsLayer()
const sketchViewModel = new SketchViewModel({
layer: sketchLayer,
view: view,
pointSymbol: {
type: 'simple-marker',
style: 'circle',
size: 10,
color: [255, 255, 255, 0.8],
outline: {
color: [211, 132, 80, 0.7],
size: 10
}
},
polylineSymbol: {
type: 'simple-line',
color: [211, 132, 80, 0.7],
width: 6
},
polygonSymbol: {
type: 'polygon-3d',
symbolLayers: [
{
type: 'fill',
material: {
color: [255, 255, 255, 0.8]
},
outline: {
color: [211, 132, 80, 0.7],
size: '5px'
}
}
]
},
defaultCreateOptions: { hasZ: false }
})
sketchViewModel.create(drawType) // drawType是类型
// 添加到地图中
view.map.addMany([bufferLayer, sketchLayer])
钻研不易,转载请注明出处。。。