arcgis 4.x 如何给graphic绑定鼠标浮动事件 mouseout 和 mouseover

// 监听几何响应鼠标事件
    var viewMouseover = [];
    view.on("pointer-move", (event)=>{
      view.hitTest(event).then(function(response) {
        for( var i = 0; i < viewMouseover.length; i++ ){
          var graphic = viewMouseover[i];
          if( response.results.map((e)=>{ return e.graphic }).indexOf(graphic) === -1 ){
            if( graphic.cursor ) {
              document.body.style.cursor = "";
            }
            graphic.mouseout && graphic.mouseout(graphic,event,response,view)
            viewMouseover.splice(i,1);
            i--;
          } 
        }
        response.results.map((e)=>{ return e.graphic }).forEach((graphic,i)=>{
          if( i === 0 && graphic.cursor ) {
            document.body.style.cursor = graphic.cursor;
          }
          if( viewMouseover.indexOf(graphic) === -1 ){
            viewMouseover.push(graphic);
            graphic.mouseover && graphic.mouseover(graphic,event,response,view)
          }
        })
      });
    });

  这样的话 只需要给
       graphic.mouseover = function(){}   
  graphic.mouseout = function(){}   
       就可以绑定上这2个事件了

        当然 其余的还有很多
        

view.on('mouse-wheel', (event)=>{
      // 获取摄像头位置
      var position = this.view.camera.position;
      // return;
      if( position.z < 300 ){
          view.hitTest(event).then((response)=>{
              if(response.results[0]){
                  var graphic = response.results[0].graphic;
                  graphic.wheelGo && graphic.wheelGo(graphic,event,response)
              }
          })
          return;
      }
    }, false)

    view.on("click",(event)=>{
      console.log(event.mapPoint);
      view.hitTest(event).then((response)=>{
        if(response.results[0]){
          var graphic = response.results[0].graphic;
          graphic.click && graphic.click(graphic,event,response,view);
        }
      })
    })

    view.on("double-click",(event)=>{
      console.log(event.mapPoint);
      view.hitTest(event).then((response)=>{
        if(response.results[0]){
          var graphic = response.results[0].graphic;
          graphic.dbclick && graphic.dbclick(graphic,event,response,view);
        }
      })
    })

  

上一篇:其他docker服务器连接docker私有仓库 harbor 方法


下一篇:在windows上搭建C语言开发环境——借助eclipse和MinGW