我设法向从远程 GeoJSON 资源添加的要素图层添加交互性。当我点击一个功能时,我会得到它的 ID,触发一个 AJAX 请求并在 map 区域之外的页面上显示有关该功能的一些相关信息。
我用了Select
相互作用。
我想让用户更清楚地知道他可以点击 map 上的功能。当鼠标悬停在 ol.layer.Vector
中包含的功能时,有什么方法可以将鼠标光标更改为“手”的“光标” ?
我在文档、本网站或谷歌搜索中找不到任何内容。
最佳答案
它也可以在没有 jQuery 的情况下完成:
map.on("pointermove", function (evt) {
var hit = this.forEachFeatureAtPixel(evt.pixel, function(feature, layer) {
return true;
});
if (hit) {
this.getTargetElement().style.cursor = 'pointer';
} else {
this.getTargetElement().style.cursor = '';
}
});
关于javascript - 如何在openlayers 3中更改悬停光标?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26022029/