Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to change text color on hover #4961

Closed
phiphou opened this issue Jul 9, 2017 · 2 comments
Closed

How to change text color on hover #4961

phiphou opened this issue Jul 9, 2017 · 2 comments

Comments

@phiphou
Copy link

phiphou commented Jul 9, 2017

Hi,

I'm trying to change the color of the text of a marker on mouse over, but with no luck. map.getCanvas().style.cursor = 'pointer' works well for cursor changing, but is there a way to change text color ?

I tried with map.setFilter("pois_hover", ["==", "name", features[0].properties.name]); but the text below the original text is "buggy". See http://osm.phiphou.org/vector-interactive#20/48.76276/2.67216

I want to keep the underneath layer in order to have a good text colision behaviour.

Sorry for my bad english.

Thanks

@andrewharvey
Copy link
Collaborator

https://gis.stackexchange.com/questions/tagged/mapbox-gl-js is a better place to ask for help on how do I do this type questions, as next time if someone has a similar query they can find the answer there.

Is this what you wanted? https://jsbin.com/nemipiyoco/edit?html,output

It uses the setData approach to hovers, as it is faster at least until #2874 is resolved.

@phiphou
Copy link
Author

phiphou commented Jul 10, 2017

I always forget to ask on SE, but will do so next time. You perfectly answer my question, thanks a lot ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants