Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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'); 
like image 581
David Avatar asked Aug 25 '26 18:08

David


1 Answers

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.net/dpbx96of/ ]

like image 168
stdob-- Avatar answered Aug 28 '26 08:08

stdob--



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!