cesium清除绑定事件无效,不起作用

Cesium源码 · guyu521 · 于 3年前 发布 · 4536 次阅读
 var handler1 = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);

    if (flag) {
      console.log(666)
      var h = viewer.camera.positionCartographic.height;
      if (h > 21000) {
        this.ac("本区域存在滑动沉降", true, 800);
      } else if (h < 2400 && h > 0) {
        this.ac("昭通市昭阳区靖安镇小堡子村,距离道路中心线(线位ZK1+460~ZK1+650)约100m,位于道路边坡外:-10~-30 mm/year", false, 0);
      } else {
        this.ac("本区域存在滑动沉降", true, 100);
      }
      //监控相机高度
      handler1.setInputAction(function (wheelment) {
        console.log(wheelment)
        var height = viewer.camera.positionCartographic.height;
        console.log(height, "5555")
        if (height > 21000) {
          _this.ac("", true, 800);

        } else if (height < 2400 && height > 0) {
          _this.ac("昭通市昭阳区靖安镇小堡子村,距离道路中心线(线位ZK1+460~ZK1+650)约100m,位于道路边坡外:-10~-30 mm/year", false, 0);
        } else {
          _this.ac("本区域存在滑动沉降", true, 100);
        }
      }, Cesium.ScreenSpaceEventType.WHEEL);
      //  console.log(handler1.removeInputAction(Cesium.ScreenSpaceEventType.WHEEL),handler1)
      //handler1.removeInputAction(Cesium.ScreenSpaceEventType.WHEEL)
    } else {
      handler1.removeInputAction(Cesium.ScreenSpaceEventType.WHEEL)
      viewer.scene.postProcessStages.removeAll();
      viewer.entities.removeAll();
    }

这个事代码走了else清除鼠标滑轮事件不起作用但是监听之后立马清除可以清除,有知道是为什么吗?

共收到 1 条回复
admin#13年前 0 个赞

你是想说debug加断点之后 还是 监听之后,监听不是应该的吗?

添加回复 (需要登录)
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册
Your Site Analytics