[英]Mapbox GL JS custom cursor
Is there a simple way to have a custom cursor for a map?有没有一种简单的方法可以为地图设置自定义光标? The following code I have works very nicely, it's simple too but it's just a predefined option :
我的以下代码效果很好,它也很简单,但它只是一个预定义的选项:
map.getCanvas().style.cursor = 'default';
Is it possible to have something like this?有可能有这样的东西吗? :
:
map.getCanvas().style.cursor = url('custom.png');
You can change the style of the cursor through the css of the mapboxgl canvas container :您可以通过 mapboxgl 画布容器的 css 更改光标的样式:
.mapboxgl-canvas-container { cursor: url(/path/to/cursor.png), auto !important }
[ https://jsfiddle.net/dpbx96of/ ] [ https://jsfiddle.net/dpbx96of/ ]
You can do this by converting the icon to a .cur
file;您可以通过将图标转换为
.cur
文件来实现此目的; cursor.cc is what I used. cursor.cc是我使用的。
I found that .png
will not work, but .cur
will;我发现
.png
不起作用,但.cur
会; then, stdob--'s solution will work:然后, stdob-- 的解决方案将起作用:
.mapboxgl-canvas-container { cursor: url(/path/to/cursor.CUR), auto !important }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.