rdeck_proxy | R Documentation |
Creates an rdeck()
interface for asynchronous updates of a pre-rendered rdeck map
in Shiny apps.
All rdeck props can be updated through the proxy (NULL
values will be discarded),
layers that are added to the proxy (e.g. rdeck_proxy %>% add_h3_hexagon_layer()
)
will be merged with pre-rendered rdeck layers.
Layers are merged by their id
. Matched layers will be updated in place, new layers
will be appended and hence drawn on top of all existing layers. For layer updates, you
may omit the data
prop to avoid re-serialising unchanged data. All other props will
assume their defaults if omitted.
rdeck_proxy(
id,
session = shiny::getDefaultReactiveDomain(),
map_style = cur_value(),
theme = cur_value(),
initial_bounds = cur_value(),
initial_view_state = cur_value(),
controller = cur_value(),
picking_radius = cur_value(),
use_device_pixels = cur_value(),
blending_mode = cur_value(),
layer_selector = cur_value(),
editor = cur_value(),
lazy_load = deprecated(),
...
)
id |
< |
session |
< |
map_style |
< |
theme |
< |
initial_bounds |
< |
initial_view_state |
< |
controller |
< |
picking_radius |
< |
use_device_pixels |
<
|
blending_mode |
<
|
layer_selector |
< |
editor |
< |
lazy_load |
|
... |
Additional parameters that will be forwarded to deck.gl javascript without
validation nor processing. All dots must be named and will be |
## Not run:
library(shiny)
library(dplyr)
library(h3jsr)
library(viridis)
ui <- fillPage(
rdeckOutput("map", height = "100%"),
absolutePanel(
top = 10, left = 10,
sliderInput("range", "value", 0, 1, c(0, 1), step = 0.1)
)
)
h3_data <- tibble(
hexagon = get_res0() %>%
get_children(res = 3) %>%
unlist() %>%
unique(),
value = runif(length(hexagon))
)
map <- rdeck() %>%
add_h3_hexagon_layer(
id = "h3_hexagon",
name = "hexagons",
data = h3_data,
get_fill_color = scale_color_quantize(
col = value,
palette = viridis(6, 0.3)
),
pickable = TRUE,
auto_highlight = TRUE,
tooltip = c(hexagon, value)
)
server <- function(input, output, session) {
output$map <- renderRdeck(map)
filtered_data <- reactive({
h3_data %>%
filter(value >= input$range[1] & value <= input$range[2])
})
observe({
rdeck_proxy("map") %>%
add_h3_hexagon_layer(
id = "h3_hexagon",
name = "hexagons",
data = filtered_data(),
get_fill_color = scale_color_quantize(
col = value,
palette = cividis(6, 0.3)
),
pickable = TRUE,
auto_highlight = TRUE,
tooltip = c(hexagon, value)
)
})
}
app <- shinyApp(ui, server)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.