zoukankan      html  css  js  c++  java
  • openlayers 为元素添加点击和鼠标悬停事件

     let clickSelect = new Select({
            condition: click,
            hitTolerance: 5,
          });
          clickSelect.layerName = 'dangerRiver';
          var _this = this;
          clickSelect.on('select', function (e) {
            if (e.selected.length > 0) {
              let layerName = e.target.getLayer(e.selected[0]).layerName;
              if (layerName == 'evacuationroute') {
                this.getFeatures().clear();
              } else {
                _this.mapComponent.showPopup(e.selected[0], layerName);
                this.getFeatures().clear();
              }
            }
          });
          this.mapComponent.map.addInteraction(clickSelect);

          let pointerMoveSelect = new Select({
            condition: pointerMove,
            hitTolerance: 5,
          });
          pointerMoveSelect.on('select', function (e) {
            let features = e.target.getFeatures().array_;
            if (features.length > 0) {
              let layerName = e.target.getLayer(e.selected[0]).layerName;
              if (layerName == 'evacuationroute') {
                this.getFeatures().clear();
              } else {
                _this.mapComponent.map.getTargetElement().style.cursor = 'pointer';
              }
              //this.getFeatures().clear();
            } else {
              _this.mapComponent.map.getTargetElement().style.cursor = 'auto';
            }
          });
          this.mapComponent.map.addInteraction(pointerMoveSelect);
     
    引入:
    import { click, pointerMove } from 'ol/events/condition.js';
    import Select from 'ol/interaction/Select';
    import Point from 'ol/geom/Point';
    import Feature from 'ol/Feature';
  • 相关阅读:
    visual studio 2013运行时卡顿 CPU占用超50%的解决方法
    altium designer中Net Label 使用说明
    机器学习中的目标函数、损失函数、代价函数
    我的Android天气app
    序列交换
    挑战多重部分和问题
    kmp算法模式串匹配
    poj3259
    poj3255
    Redis工具类 单机+集群
  • 原文地址:https://www.cnblogs.com/maycpou/p/14606505.html
Copyright © 2011-2022 走看看