【发布时间】:2014-09-22 20:03:40
【问题描述】:
我很难让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')
)
))
服务器.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
})
})
【问题讨论】:
-
您将地图放在
navBarPage中,该navBarPage会调整内部容器的大小。您可以选择较大的宽度和高度map1$set(width = 1600, height = 800),因为目前不支持百分比大小。但请注意,navBarPage仍会添加可能会偏移地图的填充。你需要更多的 CSS 来解决这个问题。 -
感谢 Ramnath,有没有人碰巧知道是否有办法通过
shiny传递用户的屏幕分辨率?结合这将是一个答案,但我可以将其设置为一个单独的问题。