vasturiano / globe.gl

UI component for Globe Data Visualization using ThreeJS/WebGL
https://vasturiano.github.io/globe.gl/example/world-population/
MIT License
1.97k stars 293 forks source link

Trigger polygon hover event for one of the polygons programmatically #190

Open snadir7 opened 4 months ago

snadir7 commented 4 months ago

Hello, first thank you very much for this awesome project ! I am trying to trigger the polygon hover using javascript programmatically for a precise polygon (maybe using it's latitude and longitude for example). I tried looking for a way to do so but couldn't figure it out. What I am trying to do with this is highlight to the user the position of the country related to the flag he just clicked on. Thanks !

vasturiano commented 4 months ago

@snadir7 if you know the polygon/country you wish to highlight you shouldn't need to trigger any hover functionality. Just invoke the style method you wish to change, for instance:

.polygonCapColor(d => d === highlightD  ? 'red' : 'blue')
snadir7 commented 4 months ago

Thank you ! Indeed I managed to use .polygonAltitude and .polygonCapColor for my use case !