Openlayers 遍历查找交互事件(ol.interaction)

编程入门 行业动态 更新时间:2024-10-28 18:36:50

说明

有时候需要遍历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);

更多推荐

Openlayers 遍历查找交互事件(ol.interaction)

本文发布于:2023-06-11 01:35:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1368500.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:遍历   事件   Openlayers   ol   interaction

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!