0

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)
Community
  • 1
  • 1
SatishR
  • 230
  • 3
  • 13
  • I get a map with shiny ‘0.14.1’ and mapview ‘1.2.0’ and the warning is normal since `gadmCHE$CCN_1` only contains `NA` – HubertL Oct 26 '16 at 20:02
  • Thanks for quick reply. I upgraded all 'shiny','mapview','R', and 'RStudio' to the current version @ mac, and still do not see any window. Any suggestions. – SatishR Oct 26 '16 at 20:32
  • @HubertL I deployed the code as app to see whether something wrong with my mac, but even @ shinyapps.io it does not display anything. Odd. – SatishR Oct 26 '16 at 20:52
  • Yes this is weird : I'm also using leaflet '1.0.1' – HubertL Oct 26 '16 at 20:56
  • Thanks again, it helped. I had leaflet ‘1.0.2.9003’, and reinstalling it made it to '1.0.1' and then reinstallation of mapview helped. Greatly appreciate it. – SatishR Oct 26 '16 at 21:06
  • @HubertL Now, I tried to display output from `sync`, but not successful. Any suggestions. Here is the code that I added in the server related function: `output$samplemap <- renderMapview({ m1 <- mapview(gadmCHE,zcol="ID_1") m2 <- mapview(gadmCHE,zcol="OBJECTID") sync(m1,m2) })` – SatishR Oct 26 '16 at 21:18
  • `sync`is nice but I don't think it is meant to work within Shiny – HubertL Oct 26 '16 at 21:24
  • Thanks again. I'll post with as a separate question and let me say what developers will say. – SatishR Oct 26 '16 at 21:26

0 Answers0