-
-
Notifications
You must be signed in to change notification settings - Fork 22
Open
Description
When I try to update the source of a layer using set_source() on a maplibre_compare_proxy() I get the following error:
Error on client while running Shiny app
"[object Object]" is not valid JSON
The same exact code works fine on a regular maplibre_proxy()
Here is a basic shiny app that demonstrates the issue:
library(shiny)
library(mapgl)
library(dplyr)
library(tidycensus)
tracts <- get_acs("tract", variables = "B01003_001", state = "17", county = "031", geometry = T)
block_groups <- get_acs("block group", variables = "B01003_001", state = "17", county = "031", geometry = T)
m <- maplibre() %>%
add_fill_layer(
id = "data_layer",
source = tracts,
fill_color = "blue",
fill_opacity = 0.5,
fill_outline_color = "black"
) %>%
fit_bounds(tracts)
ui <- fluidPage(
selectInput("left_data", "Left data: ", choices = c("tracts", "block groups")),
selectInput("right_data", "Right data: ", choices = c("tracts", "block groups")),
maplibreCompareOutput("compare_map"),
maplibreOutput("reg_map")
)
server <- function(input, output, session) {
output$compare_map <- renderMaplibreCompare({compare(m, m)})
output$reg_map <- renderMaplibre({m})
observeEvent(input$left_data, {
if (input$left_data == "tracts") {
source <- tracts
} else {
source <- block_groups
}
maplibre_compare_proxy("compare_map", map_side = "before") %>%
set_source(
layer_id = "data_layer",
source = source
)
maplibre_proxy("reg_map") %>%
set_source(
layer_id = "data_layer",
source = source
)
})
observeEvent(input$right_data, {
if (input$right_data == "tracts") {
source <- tracts
} else {
source <- block_groups
}
maplibre_compare_proxy("compare_map", map_side = "after") %>%
set_source(
layer_id = "data_layer",
source = source
)
})
}
shinyApp(ui, server)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels