I'm trying to use observeEvent()
to change the Mapview's x
argument to new data. I'd normally just use clearShapes()
then addPolygons()
, but need the zcol
etc. arguments.
I'd like to do something similar to the following:
server <- function(input, output) {
output$DisplayMap <- renderLeaflet(
mapview(first_data, zcol = coolCol, color = brewer.pal(12, "Set3") %>%
addControl(actionButton("Next", ">"), position = "topright")
)
observeEvent(input$Next, {
output$DisplayMap$x <- next_data # This doesn't work
})
}
I realise there's 2 issues at play (an interface to change the variable and a means to do so), and one of them probably needs React in some form or another
I think it's not possible to modify output like this (but indeed, it will be easier with MRE).
You should think about something like this:
server <- function(input, output) {
my_data <- reactiveVal(data.frame(a = 1, b = 2))
output$DisplayMap <- renderLeaflet(
mapview(my_data()[[input$Next]], zcol = coolCol, color = brewer.pal(12, "Set3") %>%
addControl(actionButton("Next", ">"), position = "topright")
)
}
Assuming input$Next
is a name of column which user can choose in GUI. This is just to show you an idea. Send MRE if you still need a help and I can edit this answer.