2
雖然代碼在閃亮之外自行工作,但我無法獲取傳單地圖以在我的閃亮應用中渲染。我沒有得到任何錯誤,所以我卡住了,任何幫助表示讚賞。Shiny/Leaflet map not rendering
樣本數據:
cleanbuffalo <- data.frame(name = c("queen","toni","pepper"),
longitude = c(31.8,32,33),
latitude = c(-24,-25,-26))
閃亮UI:
vars <- c(
"Pepper" = "pepper",
"Queen" = "queen",
"Toni" = "toni"
)
shinyUI(navbarPage("Buffalo Migration", id ="nav",
tabPanel("Interactive Map",
div(class="outer",
leafletOutput("map", width = "100%", height = "100%"),
#Panel Selection
absolutePanel(id = "controls", class = "panel panel-default", fixed = TRUE,
draggable = TRUE, top = 60, left = "auto", right = 20, bottom = "auto",
width = 330, height = "auto",
h2("Buffalo Migration"),
#Buffalo Group selection
checkboxGroupInput(
"checkGroup", label = h3("Select Buffalo to Follow"),
choices = vars,
selected = 1)
)
)
)
)
)
閃亮服務器:
library(shiny)
library(dplyr)
library(leaflet)
library(scales)
library(lattice)
shinyServer(function(input, output, session) {
output$map <- renderLeaflet({
leaflet() %>% addTiles() %>% setView(lng = 31.88, lat = -25.02, zoom=1)
})
這解決了我的問題,謝謝。我從來沒有想到這是問題。 – josh453
'?shiny :: plotOutput'中的文檔給出了原因:「請注意,對於高度,使用」auto「或」100%「通常無法按預期工作,因爲如何使用HTML/CSS計算高度。」 – SymbolixAU
加上幾個github問題[這裏](https://github.com/rstudio/shiny/issues/705)[和這裏](https://github.com/rstudio/shiny/issues/650),for例子進一步解釋 – SymbolixAU