我正在创建一个shiny 的仪表板应用程序,仪表板主体应该显示一些 map .到目前为止,让 map 扩展到身体的整个宽度没有问题,但它不知何故不愿意调整到整个高度.
传单本身已经设置为覆盖100%的高度,但它没有做到这一点.当我为传单输出使用"高度"属性时,传单对象将完全不显示,而我只剩下一个空框.
代码如下所示:
library(shinydashboard)
library(leaflet)
ui <- dashboardPage(
dashboardHeader(title = "Basic dashboard"),
dashboardSidebar(
sidebarMenu(
menuItem(
"Maps",
tabName = "maps",
icon = icon("globe"),
menuSubItem("Watersheds", tabName = "m_water", icon = icon("map")),
menuSubItem("Population", tabName = "m_pop", icon = icon("map"))
),
menuItem(
"Charts",
tabName = "charts",
icon = icon("bar-chart"),
menuSubItem("Watersheds", tabName = "c_water", icon = icon("area-chart")),
menuSubItem("Population", tabName = "c_pop", icon = icon("area-chart"))
)
)
),
dashboardBody(
tabItems(
tabItem(
tabName = "m_water",
box(
title = "Baltic catchment areas",
collapsible = TRUE,
width = "100%",
height = "100%",
leafletOutput("l_watershed")
)
),
tabItem(
tabName = "m_pop",
# Map in Dashboard
leafletOutput("l_population")
),
tabItem(
tabName = "charts",
h2("Second tab content")
)
)
)
)
server <- function(input, output) {
set.seed(122)
histdata <- rnorm(500)
output$l_watershed <- renderLeaflet({
leaflet(height = "100%") %>% addTiles() %>% setView(19.08, 60.25, zoom = 4) %>%addWMSTiles(
"http://62.236.121.188/arcgis/services/DataAndMaps/Background/MapServer/WMSServer?",
layers = "11",
options = WMSTileOptions(
format = "image/png",
transparent = TRUE
),
attribution = "Catchment area provided by HELCOM"
)
})
output$l_population <- renderLeaflet({
leaflet(height = "100%") %>% addTiles() %>% setView(19.08, 60.25, zoom = 4) %>%addWMSTiles(
"http://62.236.121.188/arcgis/services/DataAndMaps/Background/MapServer/WMSServer?",
layers = "17",
options = WMSTileOptions(
format = "image/png",
transparent = TRUE
),
attribution = "Population data provided by HELCOM"
)
})
}
shinyApp(ui, server)