qfes / rdeck

Deck.gl widget for R
https://qfes.github.io/rdeck
MIT License
97 stars 0 forks source link

Enable layer visibility update from shiny #44

Closed anthonynorth closed 2 years ago

anthonynorth commented 2 years ago

A layer's visibility cannot be changed if the following conditions are met:

https://github.com/anthonynorth/rdeck/blob/master/widget/widget.tsx#L49-L50

This constraint exists because add_x_layer() updates all of a layer's props, but the layer's visibility cannot (currently) be known in shiny. Updating a layer's visibility every time a reactive changes would be an irritating user experience.

Proposed change: visible = NULL to use the state in the browser, TRUE / FALSE to change it.

Example:

observe({
  rdeck_proxy("map") |>
    add_h3_hexagon_layer(
      id = "layer_id",
      data = some_new_data(),
      # client = truth
      visible = NULL,
    )
})