dvgis / dc-sdk

DC-SDK is based on the open source project Cesium for the second development of two three-dimensional WebGis application framework , the framework optimizes the use of Cesium and adds some additional features , designed for developers to quickly build WebGis application.🌎
http://dc.dvgis.cn
Apache License 2.0
824 stars 256 forks source link

事件冒泡支持 #159

Closed ShenWeiQun closed 1 year ago

ShenWeiQun commented 1 year ago

有计划对事件冒泡的支持吗? 当前现象

ShenWeiQun commented 1 year ago

最好是个开关控制,可以选择是否要冒泡

cavencj commented 1 year ago

目前就是故意设计成这样的, 开发时,可以根据实际情况针对设置事件

ShenWeiQun commented 1 year ago

那么当前版本如果要实现冒泡能实现吗?

cavencj commented 1 year ago

只要在mouseevent中把事件抛出去

ShenWeiQun commented 1 year ago

多谢,这样操作可以实现冒泡,给后来有需要的记录一下

      let layer = new DC.VectorLayer('layer')
      viewer.addLayer(layer)

      let point = new DC.Point(new DC.Position(127, 31))
      layer.addOverlay(point)
      // 监听实体模型点击事件
      point.on(DC.MouseEventType.CLICK, e => {
        console.log("实体模型 ==")
        const event = layer.layerEvent.getEvent(DC.MouseEventType.CLICK)
        event.raiseEvent(e)
      })
      // 监听图层点击事件
      layer.on(DC.MouseEventType.CLICK, e => {
        console.log("图层 ==")
        const event = viewer.viewerEvent.getEvent(DC.MouseEventType.CLICK)
        event.raiseEvent(e)
      })
      // 监听地图点击事件
      viewer.on(DC.MouseEventType.CLICK, e => {
        console.log("地图 ===")
      })

      viewer.flyTo(layer)

      // console.log
      // 实体模型 ==
      // 图层 ==
      // 地图 ===
cavencj commented 1 year ago

好的