Closed SymbolixAU closed 5 years ago
example of updating titles
library(shiny)
library(shinydashboard)
library(mapdeck)
library(sf)
ui <- dashboardPage(
dashboardHeader()
, dashboardSidebar(
actionButton(
inputId = "shuffle"
, label = "shuffle"
)
)
, dashboardBody(
mapdeck::mapdeckOutput(
outputId = "map"
, height = "600px"
)
)
)
server <- function(input, output) {
df <- roads[1:500, ]
df$colour <- "#FFFFFF"
output$map <- mapdeck::renderMapdeck({
mapdeck( location = c(145, -37.85), zoom = 10, style = mapdeck_style("dark")) %>%
add_path(
data = df
, update_view = FALSE
, stroke_colour = "colour"
)
})
observeEvent({input$shuffle},{
df$colour <- "#FFFFFF"
n <- sample(1:nrow(df), size = 1)
r <- sample(1:nrow(df), size = n)
df[r, "colour"] <- "#00FF00"
mapdeck_update(
map_id = "map"
) %>%
add_path(
data = df
, stroke_colour = "colour"
, stroke_width = 20
, update_view = FALSE
) %>%
add_title(
title = paste0(n, " roads are coloured")
, layer_id = "colouered"
) %>%
add_title(
title = paste0(nrow(df) - n, " roads are not coloured")
, layer_id = "notcoloured"
)
})
}
shinyApp(ui, server)
Overlay text on the map. Would work like
And controllable by CSS.
TODO
add_title()
calls with the samelayer_id
update an existing titleclear_title()