首页 / 浏览问题 / 云GIS / 问题详情
iClient Openlayers图层如何为图层的显示/隐藏设置对应的事件
250EXP 2023年06月09日
在iclient for openlayers中通过layerswitcher去控制之后追加的专题图的显隐

这个专题图在追加时设置了

 themeSource.on('mousemove', function (e) { 功能 })

然后追加了

var pointerInteraction = new ol.interaction.Pointer({
            handleMoveEvent: function (event) {
                themeSource.fire('mousemove', event);
            }
        });
        map.addInteraction(pointerInteraction);

实现了在鼠标移动到专题图的点上的时候自动显示属性的功能,但通过layerswitcher功能隐藏这个图层的显示后,这个显示属性的功能仍在生效。

请问有没有什么办法能够监控这个图层的显示或隐藏,显示时让他添加上述功能,隐藏时让他关闭上述功能?

1个回答

您好,您可以获取到对应图层的可见状态,根据可见状态设置if判断,图层可见时添加mousemove事件,不可见时不添加该事件
3,143EXP 2023年06月09日
...