Closed lvallata closed 3 years ago
Sorry for the long silence.
Seems like you need to update the group
argument when input$potatoes
changes:
This works for me:
library(shiny)
library(leaflet)
library(leafpop)
library(ggplot2)
ui = fluidPage(
sliderInput(inputId = "potatoes",
label = "Potatoes:",
min = 1,
max = 10,
value = 2,
step = 1,
animate = F,
width = '100%'),
leafletOutput('my_map', height = 700)
)
server = function(input, output, session) {
output$my_map <- renderLeaflet({
my_map <- function(my.var = character()){
my.plot <- ggplot(mtcars, aes(cyl, mpg)) + geom_line()
m <- leaflet() %>%
addTiles(urlTemplate = 'https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png') %>%
setView(lng = 10,
lat = 49,
zoom = 4) %>%
addCircleMarkers(lng = c(10, 10),
lat = c(49, 50),
group = paste0('A', input$potatoes),
label = my.var
) %>%
addPopupGraphs(list(my.plot,my.plot),
group = paste0('A', input$potatoes),
width = 500, height = 300)
return(m)
}
my_map(input$potatoes)
})
}
shinyApp(ui, server)
Here is the link to stackoverflow post (reproducible example inside). https://stackoverflow.com/questions/60741317/shiny-leafpopaddpopupgraphs-bug-looking-for-a-walkaround
Best, Lukic