最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Mapbox GL JS custom cursor - Stack Overflow

programmeradmin0浏览0评论

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'); 

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'); 
Share Improve this question asked Jul 2, 2018 at 9:26 David David 8354 gold badges17 silver badges54 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 4

You can change the style of the cursor through the css of the mapboxgl canvas container :

.mapboxgl-canvas-container { cursor: url(/path/to/cursor.png), auto !important }

[ https://jsfiddle/dpbx96of/ ]

You can do this by converting the icon to a .cur file; cursor is what I used.

I found that .png will not work, but .cur will; then, stdob--'s solution will work:

.mapboxgl-canvas-container { cursor: url(/path/to/cursor.CUR), auto !important }
发布评论

评论列表(0)

  1. 暂无评论