【Mars3d 基础- 矢量数据】标绘完成事件

本文详细介绍了如何使用Mars3D库进行矢量图形的矩形绘制,并重点讲解了success回调和drawCreated事件的绑定,帮助开发者掌握图形绘制后的交互操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

通常我们需要自己绘制一个矢量数据,绘制完成之后在进行下一步的需求,


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)
})

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值