简体   繁体   English

如何使鼠标指针悬停在要素悬停上,但前提是弹出窗口未将其悬停?

[英]How to get a pointer cursor on feature hover but only if not covered by a popup?

I change the mouse cursor to "pointer" on features the following way: 我通过以下方式将鼠标光标更改为功能上的“指针”:

// change mouse cursor when over marker
map.on('pointermove', function(e) {
    var pixel = map.getEventPixel(e.originalEvent);
    var hit = map.hasFeatureAtPixel(pixel);
    map.getTarget().style.cursor = hit ? 'pointer' : '';
});

The problem is, when I open a popup, the cursor changes even if the feature is covered by the popup (see https://jsfiddle.net/Ld9rup3v/2/ : click on the lower point and you can hover over the upper point through the popup). 问题是,当我打开一个弹出窗口时,即使该弹出窗口覆盖了该功能,光标也会更改(请参阅https://jsfiddle.net/Ld9rup3v/2/ :单击较低的点,然后可以将鼠标悬停在较高的点上通过弹出窗口)。 How can I prevent that? 我该如何预防?

好的,我找到了一个简单的CSS解决方法:

.popover { cursor:default; }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM