2017-09-19 74 views
1

我試圖從forecast.io的天氣預報嵌入閃亮的儀表板。我原本遇到了與符號的問題,但看到一篇文章提供瞭如何使用特殊字符格式化HTML代碼的示例。但是,當我運行該應用程序時,我看到一個簡單的「未找到」,儘管我知道該鏈接正常工作並且格式正確。我不確定我錯過了什麼。嵌入天氣iframe到閃亮的儀表板

library(shiny) 
library(shinydashboard) 

ui <- dashboardPage(
    dashboardHeader(title = "Dashboard"), 
    dashboardSidebar(
    sidebarMenu(
     menuItem("Dashboard", tabName = "dashboard", icon = icon("dashboard")) 
    ) 
), 

    dashboardBody(
    tabItems(
     # First tab content 
     tabItem(tabName = "dashboard", 
       fluidRow(

       column(12, 
         mainPanel(htmlOutput("frame") 
         ) 
       ) 
      ) 
    ) 
    ) 
) 
) 

server <- shinyServer(function(input, output) { 

    output$frame <- renderUI({ 
    tags$iframe(id = 'app', src = url("https://forecast.io/embed/#lat=42.3583&lon=-71.0603&name=Downtown Boston"), width = '100%') 
    }) 

}) 

shinyApp(ui,server) 

Screen capture of error in Shiny Dashboard

+0

你試過編碼的空間網址是什麼? – Oswald

回答

1

更新與插入儀表盤

我轉移URL從服務器到用戶界面:

library(shiny) 
library(shinydashboard) 

ui <- dashboardPage(
    dashboardHeader(title = "Dashboard"), 
    dashboardSidebar(
     sidebarMenu(
      menuItem("Dashboard", 
        tabName = "dashboard", 
        icon = icon("dashboard") 
      ) 
     ) 
    ), 

    dashboardBody(
     tabItems(
      tabItem(
       tabName = "dashboard", 
       fluidRow(
        tags$iframe(
         seamless = "seamless", 
         src = "https://forecast.io/embed/#lat=42.3583&lon=-71.0603&name=Downtown Boston", 
         height = 800, width = 1400 
        ) 
       ) 
      ) 
     ) 
    ) 
) 

server <- function(input, output) {} 
shinyApp(ui, server) 

enter image description here

+0

@nicktb如果我的解決方案有助於解決問題,您可以接受 – PoGibas

+0

感謝您的留言,但它對我無效。在儀表板頁面上,它只顯示一個URL鏈接,上面寫着「我的網址」,它將我帶入預測。從「未發現」中肯定會有改進,但不是我期望的嵌入。我沒有任何運氣嵌入任何iframe(甚至使用來自其他例子的腳本),所以我認爲這是系統性的。 – nicktb

+0

@nicktb我更新了我的答案,似乎這解決了你的問題 – PoGibas