vasturiano / globe.gl

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

Trigger the elevation of a single polygon #92

Open possec20 opened 2 years ago

possec20 commented 2 years ago

I want to be able to have an input where you can write the name of a country, and then it elevates. However, I can't figure out how I can trigger it. I only found onclick and onhover functions and was wondering, what I could do. Something like that: image image

possec20 commented 2 years ago

This is the code I already have (mostly Choropleth source code):

<!DOCTYPE html>

Vite App
possec20 commented 2 years ago

It formatted a bit weird, so here is a photo: image

vasturiano commented 2 years ago

@possec20 you should just need to invoke polygonAltitude when you want that logic to change, for example on country selection. For instance if your select box has a onCountrySelection, you could do something like:

onCountrySelection(country => world.polygonAltitude(d => d.properties.NAME = country ? 0.4 : 0.06))
possec20 commented 2 years ago

image Now it just says, that "world" is not defined image

vasturiano commented 2 years ago

@possec20 where you're declaring that function, the variable world is not in scope.

possec20 commented 2 years ago

So it isn't a globle variable. I tried puttting the declaration of "world" out of the "fetch", but of course that breaks the whole thing. How can I make it to a globle variable, so I can access it everywhere?