制作rMaps Leaflet Maps全屏

时间:2014-07-31 01:02:25

标签: r leaflet shiny rcharts

我在rMaps - leaflet中使R shiny全屏显示时遇到了一些困难。谁能指出我正确的方法呢?

ui.R:

library(shiny);library(rCharts)
shinyUI(navbarPage("rMaps Leaflet Sizing",
  tabPanel("Map",
#  tags$style('.leaflet {height: 100%; width: 100%}'), --no change 
    mapOutput('mapPlotJSON')
  )
))

server.R:

library(shiny);library(rCharts);library(rMaps)
shinyServer(function(input, output, session) {
  output$mapPlotJSON <- renderMap({
    map1 = Leaflet$new()
    map1$setView(c(45.5236, -122.675), 13)
    map1$tileLayer(provider ='Stamen.Terrain')
#   map1$set(width = "100%", height = "100%") --doesn't show map
    map1
  })
})

2 个答案:

答案 0 :(得分:1)

我遇到了同样的问题。我建议使用以下页面中的提示 http://www.d3noob.org/2014/02/make-your-leafletjs-map-full-screen.html

例如,在.css文件中添加:

body {
  height: 100%;
  width: 100%;
}

html {
  height: 100%;
  width: 100%;
}

.leaflet {
  height: 100%; 
  width: 100%;
}

答案 1 :(得分:0)

应为map1$fullScreen(TRUE)

请参阅https://github.com/ramnathv/rCharts/issues/290#issue-21794686

中的示例