【问题标题】:Making rMaps Leaflet Maps Full-screen制作 rMaps 传单地图全屏
【发布时间】:2014-09-22 20:03:40
【问题描述】:

我很难让rMaps leafletR-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 传递用户的屏幕分辨率?结合这将是一个答案,但我可以将其设置为一个单独的问题。

标签: r leaflet shiny rcharts


【解决方案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%;
}

【讨论】:

    【解决方案2】:

    应该是map1$fullScreen(TRUE)

    参见https://github.com/ramnathv/rCharts/issues/290#issue-21794686中的示例

    【讨论】:

    • 感谢您对此进行调查。那对你有用吗?我仍然得到800x400。此外,虽然它没有出现,但我想回忆一下 fullScreen 是一种添加启用全屏查看的按钮的方法。更清楚地说,我正在寻找它来自动填充仍然显示导航栏的页面。仅供参考,我已经加载了这些:rMaps_0.1.1 rCharts_0.4.2 shiny_0.10.1。
    • 您好,我也有同样的问题...有人知道解决方案吗?
    猜你喜欢
    • 2020-08-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-27
    相关资源
    最近更新 更多