Shiny/Leaflet map not rendering
我无法获得要在闪亮的应用程序中呈现的Leaflet地图,尽管代码本身在闪亮的外部也可以工作。我没有收到任何错误,所以我被卡住了,我们将不胜感激。
样本数据:
1 2 3 | cleanbuffalo <- data.frame(name = c("queen","toni","pepper"), longitude = c(31.8,32,33), latitude = c(-24,-25,-26)) |
闪亮的用户界面:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | 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) ) ) ) ) ) |
发光服务器:
1 2 3 4 5 6 7 8 9 10 | 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) }) |
由于leafletOutput中的
我不知道为什么会这样,但是如果您想在
默认情况下,宽度设置为
1 | leafletOutput(outputId, width ="100%", height = 400) |