通常我们需要自己绘制一个矢量数据,绘制完成之后在进行下一步的需求,
graphicLayer.startDraw({
type: "rectangle",
style: {
fill: true,
color: "rgba(255,255,0,0.2)",
outline: true,
outlineWidth: 2,
outlineColor: "rgba(255,255,0,1)"
}
})
在上面我们完成了一个"矩形"的绘制,那么绘制完成之后绑定事件主要有两种:
一、success的回调
graphicLayer.startDraw({
type: "rectangle",
style: {
fill: true,
color: "rgba(255,255,0,0.2)",
outline: true,
outlineWidth: 2,
outlineColor: "rgba(255,255,0,1)"
},
success:(graphic)=>{
console.log(graphic)
}
})
二、全局绑定 drawCreated 事件
graphicLayer.on(mars3d.EventType.drawCreated, (e: any) => {
console.log(e.graphic)
})