(ArcGIS-03)ArcGis之光标图层停留及点击弹窗事件

光标停留

原理,整个MapView增加事件光标滑动处理函数,函数中:滑动进入自定义图层时,记录标记为Y,离开图层时,记录标记为N,当标记变化为Y时,添加计时器,。

this.view.on('pointer-move', this.pointerMoveHandler);//添加光标滑动处理函数
/**************************************
 * 光标滑动处理器
 **************************************/
pointerMoveHandler(evt) {
  //划过图标时,展示设备信息
  this.view.hitTest(evt).then(this.config);
},
/*********************************************************
 * 当光表进入设备图标时 初始化计时器,然后开始计时,当计时到一定事件后,展示信息
 * 当光标离开设备图标时 清除计时器
 *********************************************************/
config(response) {
  if (response.results.length) {
    this.judgeTimer = setTimeout(() => {
      console.log("-------光标一直在图标上,展示设备详细信息------")
      this.$refs.deviceInfo.view(response.results[0].graphic.attributes);
      this.judgeTimer = null;
      this.polling = null;
      clearTimeout(this.judgeTimer);
      clearInterval(this.polling);
    }, 1000);
  } else {
    this.judgeTimer = null;
    this.polling = null;
    clearTimeout(this.judgeTimer);
    clearInterval(this.polling);
  }
},

效果:

当光标滑动到图标上时,停留一秒后,页面打开一个弹窗展示我们的相关信息。

此处因为this.$refs.deviceInfo是一个普通弹窗页面,就不提供代码和内容,也不提供截图了,自己可以将this.$refs.deviceInfo.view(response.results[0].graphic.attributes);替换成alert("1111111111111")测试即可,

弹窗事件

let _point = new Point({
  type: "point",  // autocasts as new Point()
  longitude: 100,
  latitude: 20
})
icon = require('@/assets/image/video.jpg');
let _symbol = new PictureMarkerSymbol({angle: 20, url: icon, width: 20, height: 20})
let color = [4, 4, 4]//默认布防 颜色为绿色
if (item.defenceInfo.defenceType === "2") {//撤防 颜色修改为红色
  color = [255, 255, 255]
}
let textSymbol = {
  type: "text",
  borderLineColor: [48, 242, 120],
  borderLineSize: 1,
  backgroundColor: [0, 0, 0],
  haloColor: color,
  text: item.deviceName,
  xoffset: 1,
  yoffset: 12,
  //font: {size: 12,}
}
let innerHTML = '<table><tbody>' +
  '<tr><th>设备名称</th><td>' + item.deviceName + '</td><th>设备编码</th><td>' + item.deviceCode + '</td></tr>' +
  '<tr><th>设备类型</th><td>' + item.deviceTypeName + '</td><th>生产厂商</th><td>' + item.manufacturer + '</td></tr>' +
  '<tr><th>归属线路</th><td>' + item.belongLineName + '</td><th>所属区间</th><td>' + item.belongAreaName + '</td></tr>' +
  '<tr><th>IP地址</th><td>' + item.ipAddr + '</td><th>端口</th><td>80</td></tr><tr><th>登录账号</th><td>admin</td>' +
  '<th>登录密码</th><td>admin</td></tr></tbody></table>'
let _popup = new PopupTemplate({
  title: '<p><strong>设备详情</strong></p>',
  content: innerHTML,
  width: 20,
})
let graphic = new Graphic({
  geometry: _point, symbol: _symbol,popupTemplate: _popup,
});
graphic.attributes = item;
this.deviceLayer.add(graphic);

  • 18
    点赞
  • 22
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值