Reputation: 51
I would like to use the mapview
package - it is quite fast - in shiny.
In order to render the mapview
object the @map
trick works like a charm.
However, as opposed to ggplot2
, making the mapview_leaflet
object reactive, is quite complicated. In my shiny app, I would like to make the color palette interactive. Is that possible?
library(mapview)
library(shiny)
server <- function(input, output) {
output$test <- renderLeaflet({
req(input$obs)
rws <- input$obs
mapview(breweries91[1:rws,])@map
})
}
ui <- fluidPage(
sidebarLayout(
sidebarPanel(
sliderInput("obs", "Number of observations:", min = 1, max = nrow(breweries91@data), value = nrow(breweries91@data))
),
mainPanel(
leafletOutput('test')
)
)
)
shinyApp(ui = ui, server = server)
Upvotes: 1
Views: 1005
Reputation: 51
I can confirm, that by making the input data and hence the mapview object reactive, mapview and shiny work like a charm with the @map hack. In conjunction with the leaflet-easyprint plugin it is a very useful tool for creating and exporting maps.
Upvotes: 0