2016-08-22 4 views
2

내 반짝이는 앱에서 렌더링 할 전단지를 얻을 수는 없지만 코드가 반짝이는 곳 밖에서 작동합니다. 나는 어떤 오류도 발생하지 않아 붙어서 도움이된다.반짝이는/리플렛지도가 렌더링되지 않습니다

샘플 데이터 :

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) 
    }) 

답변

4

이 때문에 leafletOutput에서 height 매개 변수 작동하지 않습니다. 이상하게도, %에 지정하면 맵이 표시되지 않지만 "px"(또는 문자열에 강제로 "px"가 추가되는 번호)를 사용하면 잘 작동합니다.

leafletOutput("map", width = "75%", height = "500px") 수율 :

enter image description here

이런 일이 발생하는 이유는 모르겠지만 당신이 %leafletOutput의 높이를 지정하기를 원한다면 당신이 div로 포장하고 그것을 적절한 높이를 줄 수 . 폭 100%로 설정된 400 픽셀과 기본적으로 높이


. 따라서 이러한 매개 변수를 지정할 필요가 없습니다. 출력 크기를 변경하려는 경우에만 수행 할 것입니다.

leafletOutput(outputId, width = "100%", height = 400) 
+1

내 문제가 해결되었습니다. 감사합니다. 나는이 문제를 결코 짐작하지 않았을 것이다. – josh453

+1

'? shiny :: plotOutput'의 문서는 이유를 설명합니다 : "height"는 HTML/CSS로 높이를 계산하기 때문에 "auto"또는 "100 %"를 사용하면 일반적으로 예상대로 작동하지 않습니다. – SymbolixAU

+1

더하기 github 문제 [여기] (https://github.com/rstudio/shiny/issues/705) [및 여기] (https://github.com/rstudio/shiny/issues/650) 추가 설명을위한 예제 – SymbolixAU

관련 문제