Ich bin dabei, eine Shiny-Dashboard-Anwendung zu erstellen, in der der Dashboard-Body einige Maps anzeigen soll. Bislang kein Problem, die Karte über die gesamte Breite des Körpers zu erweitern, aber sie ist irgendwie nicht bereit, sich auf die volle Höhe einzustellen. So erhalten Sie Leaflet für R: 100% von Shiny Dashboard height
Die Broschüre selbst ist bereits auf 100% der Höhe festgelegt, aber es ist nicht der Trick. Sobald ich das height-Attribut für das leafletOutput verwende, wird das leaflet-Objekt überhaupt nicht mehr angezeigt, und ich habe ein leeres Feld.
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)
Ich liebe dich so sehr! Ich folterte mich für einen Monat, um zu finden, wie es geht –
Wow, ich habe so viele verschiedene Lösungen probiert und mindestens 15-20 Stunden mit diesem Problem verbracht. Dies ist der erste (einzige?) Weg, wie es für mich funktioniert hat. Vielen Dank!! <3 –