【Mars3d】点位停止编辑时获取点位空间坐标位置信息等回传给后端

示例地址:

http://mars3d.cn/editor-vue.html?id=graphic/primitive/point

当前问题:

右键编辑点,开始编辑对象--停止编辑。需要保存编辑后的点到数据库,需要对应的停止编辑函数。

   {
        text: "停止编辑对象",
        icon: "fa fa-edit",
        show: function (e) {          
          console.log('停止编辑对象,获取对象信息');
          const graphic = e.graphic
          if (!graphic || !graphic.hasEdit) {
            return false
          }
          return graphic.isEditing
        },
        callback: (e) => {
          console.log('停止编辑对象000callback');
          const graphic = e.graphic
          if (!graphic) {
            return false
          }
          if (graphic) {
            graphic.stopEditing()
          }
        }
      },

解决方案:

停止编辑后,能够获取编辑点的坐标、高度、属性信息,回传给后端保存。

1.可以使用下面事件监听。

graphicLayer.on(mars3d.EventType.editStop, function (e) {
 
})

2.或参考图上标绘功能,增加其他事件做完整的处理。

  // 矢量数据创建完成
  graphicLayer.on(mars3d.EventType.drawCreated, function (e) {
    if (formState.hasEdit || props.customEditor) {
      showEditor(e.graphic)
    }
  })

  // 单击开始编辑
  graphicLayer.on(mars3d.EventType.editStart, (e: any) => {
    setTimeout(() => {
      // 属性面板打开时,点击其他的矢量数据,打开后会被下面的执行关闭
      showEditor(e.graphic)
    }, 150)
  })
  // 修改了矢量数据
  graphicLayer.on([mars3d.EventType.editMovePoint, mars3d.EventType.editStyle, mars3d.EventType.editRemovePoint], function (e) {
    updateWidget("graphic-editor", {
      data: {
        graphic: markRaw(e.graphic)
      }
    })
  })
  // 停止编辑
  graphicLayer.on([mars3d.EventType.editStop, mars3d.EventType.removeGraphic], function (e) {
    setTimeout(() => {
      if (!graphicLayer.isEditing) {
        if (props.customEditor) {
          emit("onStopEditor")
        } else {
          disable("graphic-editor")
        }
      }
    }, 100)
  })
相关推荐
我命由我1234523 分钟前
微信小程序 - 自定义实现分页功能
前端·微信小程序·小程序·前端框架·html·html5·js
程序员黄同学1 小时前
请谈谈 Vue 中的 key 属性的重要性,如何确保列表项的唯一标识?
前端·javascript·vue.js
繁依Fanyi1 小时前
巧妙实现右键菜单功能,提升用户操作体验
开发语言·前端·javascript·vue.js·uni-app·harmonyos
前端御书房1 小时前
前端防重复请求终极方案:从Loading地狱到精准拦截的架构升级
前端·javascript
web182854825121 小时前
nginx 部署前端vue项目
前端·vue.js·nginx
zy0101011 小时前
HTML标签
前端·css·html
程序员黄同学1 小时前
解释 Vue 中的虚拟 DOM,如何通过 Diff 算法最小化真实 DOM 更新次数?
开发语言·前端·javascript
蓝谷芮济2 小时前
二:前端发送POST请求,后端获取数据
前端
果粒chenl2 小时前
css+js提问
前端·javascript·css
memorycx2 小时前
Vue02
前端·javascript·vue.js