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

Implement subsequent additionof layer data #108

Open schorschebob opened 2 years ago

schorschebob commented 2 years ago

Is your feature request related to a problem? Please describe. Over the duration of my project, pins should appear on the globe in a timed manner. I would love it if it would be possible to subsequently add entries to layers like the HTML Elements Layer. (Potentially also remove by index?)

Describe the solution you'd like Add a method like htmlElementsPush({obj}) or htmlElementsRemove({index}) to update the respective layer.

Describe alternatives you've considered My current approach is this: Reset the all records - including the few new ones - via globe.htmlElementsData([...globe.htmlElementsData(), newPin]).

I love your project keep up the good work!

vasturiano commented 2 years ago

@skgeorgi thanks for reaching out.

If this module would surface a addHtmlElement method, its internal implementation would look very close to what you already mentioned:

globe.htmlElementsData([...globe.htmlElementsData(), newElement])

This has the potential of snowballing the API, because you would also want the ability to add multiple items, remove items, swap, slice, sort, etc. All these functions are available natively in vanilla js for array manipulation.

While I understand the motivation for this request, I find it a more generic approach to leave data manipulation functions out of this module and let consumers do it freely before passing the data on to the component.