问题
I’m trying to have two spatial plots side-by-side in shiny, and I was suggested a powerful function, sync
of mapview
. sync
allows to have multiple maps for comparison, a great feature, but unable to figure out integrating or calling its output in shiny.
I have gone through ‘mapview for shiny’ and other related links mapview/shiny. The former suggested using renderMapview
and mapviewOutput
, however it did not work, i.e., no map being displayed. Please see the reproducible code. Also, I tried using @map
slot of mapview
object in renderLeaflet
and calling it via leafletOutput
- did not work. In both cases, a shiny window pops up and does not display anything. However, do see the following message in the command window: Warning in spCheckObject(x) : Columns CCN_1 in attribute table contain only NA values and are dropped. - it is related to the data base and confirms that mapview command is being executed but does not provide any leads on absence of plots. Greatly appreciate suggestions or clues on displaying mapview geneated plots in shiny.
library(shiny)
library(mapview)
ui <- fluidPage(
mapviewOutput("samplemap"),
p()
)
server <- function(input, output, session) {
output$samplemap <- renderMapview({
mapview(gadmCHE)
})
}
shinyApp(ui, server)
来源:https://stackoverflow.com/questions/40270966/display-of-mapview-object-in-shiny