javascript - Mapbox GL JS custom cursor - Stack Overflow

Is there a simple way to have a custom cursor for a map? The following code I have works very nicely, i

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 }

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742367170a4430546.html

相关推荐

  • javascript - Mapbox GL JS custom cursor - Stack Overflow

    Is there a simple way to have a custom cursor for a map? The following code I have works very nicely, i

    1天前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信