R闪亮的应用程序仅在浏览器中显示一半页面

时间:2018-11-05 03:47:34

标签: r shiny leaflet

我检查了帖子Shiny app is only half of browser window,并尝试了JJ1603的建议。 我加了

options = list(height = 1080)

但是我的地图仍在浏览器中显示一半页面。

我也尝试过

library("htmlwidgets")

window_height <- JS('window.innerHeight')
window_width <- JS('window.innerWidth')

# Run the application 
shinyApp(ui = ui, server = server, options = list(height = window_height, width = window_width))

但它仍然无法正常工作。

我的代码

# Define UI for application
ui <- fluidPage(     
  leafletOutput("mymap")
)

# Define server
server <- function(input, output) {     
  data <- read.csv("dat.csv")    
  })


  output$mymap <- renderLeaflet({
    leaflet(data) %>%           
      addProviderTiles("Esri.WorldImagery") %>%          
      addCircleMarkers(lng = ~ long, 
                       lat= ~ lat, 
                       color = "#00d4ff", 
                       radius = factor(data$freq),
                       label = lapply(labs, HTML),
                       clusterOptions = markerClusterOptions()
      )
  })
}
# Run the application 
# shinyApp(ui, server)
shinyApp(ui = ui, server = server, options = list(height = window_height, width = window_width))

1 个答案:

答案 0 :(得分:2)

这有效:

ui <- fluidPage(

  leafletOutput("mymap", height = "95vh")
)

感谢吉姆·托德=)