zoukankan      html  css  js  c++  java
  • Openlayers 遍历查找交互事件(ol.interaction)

    说明

    有时候需要遍历openlayers的交互事件,并根据不同类型进行操作/监控。

    解决方案

    方法一:实现了找到交互事件中的Select事件,并删除

    map.getInteractions().forEach(function (interaction) {
                if (interaction instanceof ol.interaction.Select) {
                    map.removeInteraction(interaction);
                }
            });
    

    方法二:其实还有另一种写法,getArray()获取到的是Interactions的数组,可以用操作数组的方式去操作

    var selectInteraction = map
            .getInteractions()
            .getArray()
            .find(interaction => {
              return interaction instanceof ol.interaction.Select;
            });
    map.removeInteraction(selectInteraction);
    
  • 相关阅读:
    es6
    ES6
    ES6
    css3
    滚动穿透的6种解决方案【已自测】
    css特效
    css布局
    css布局
    js
    【消灭代办】第5周
  • 原文地址:https://www.cnblogs.com/giser-s/p/12124075.html
Copyright © 2011-2022 走看看