Mapbox-gl-js: Support a "cursor" style property

Created on 30 Jun 2015  Â·  8Comments  Â·  Source: mapbox/mapbox-gl-js

It would be great to use pointer cursor on layers with interactive: true style values.
For example I'm adding placemarks layer from geojson data and I want to let the users know what features is clickable on the map.
Thank you.

feature mapbox.js → GL JS

Most helpful comment

Here is an example implementation of making the cursor into a pointer: http://bl.ocks.org/danswick/4906b495e0b206758f71

All 8 comments

Here is an example implementation of making the cursor into a pointer: http://bl.ocks.org/danswick/4906b495e0b206758f71

This feature will be very useful alongside #1002.

We will probably want to implement this in tandem with #200

I think that with the new delegated events syntax (map.on('mouseenter', 'layer', () => { ... }), it's easy enough so that it's not necessary to introduce a new style property for this.

The easy solution that you mention, (map.on('mouseenter', 'layer', () => { ... }), consistently throws errors. The layer 'markers' does not exist in the map's style and cannot be queried for features It still works, but to have a solution that doesn't give errors would be cool.

This sounds like an unrelated error @linx97 I just tried the map.on('mouseenter', 'marker', () => {...}) solution and it worked without errors. Make sure that you have all your layers named properly without typos.

suppose it should be working after style fully loaded (use map.on('load', () = { ... });)

yes, looking back 3,5 years on this PR handling mouseenter events looks as a great solution!

When there are overlapping layers, a symbol layer that can show up on top of a fill layer, mouseenter and mouseleave leads to a flicker if you want a pointer cursor for both layers.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rasagy picture rasagy  Â·  3Comments

shotor picture shotor  Â·  3Comments

iamdenny picture iamdenny  Â·  3Comments

aendrew picture aendrew  Â·  3Comments

BernhardRode picture BernhardRode  Â·  3Comments