在shinyapps.io上部署时,.html plotGoogleMap不会加载闪亮的应用程序

时间:2014-06-10 13:44:27

标签: r shiny plotgooglemaps

我正在尝试在线创建一个闪亮的应用plotGoogleMap。 本地应用程序运行正常,但通过shinyapps上传到shinyapps.io时,.html地图无法加载。

任何想法如何解决这个问题?


请参阅下面的代码。

ui.R

library('markdown')
library('shiny')

shinyUI(navbarPage("plotGooleMaps in shinyapps",
                   mainPanel(uiOutput('mymap'))
                  )
       )

server.R

library('shiny')
library('plotGoogleMaps')

shinyServer(function(input, output){
  output$mymap <- renderUI({
    data(meuse)
    coordinates(meuse) = ~x+y
    proj4string(meuse) <- CRS("+init=epsg:28992")
    m <- plotGoogleMaps(meuse, filename = 'myMap1.html', openMap = F)
    tags$iframe(
      srcdoc = paste(readLines('myMap1.html'), collapse = '\n'),
      width = "900Px",
      height = "500Px"
      )
  })
})

使用 shinyapps部署应用

library('shinyapps')
setwd("~/working directory where ui.R and server.R are located locally")
deployApp()

这是错误日志,但我不知道从中得出什么结论:

[blocked] The page at 'about:srcdoc' was loaded over HTTPS, but ran 
insecure content from 'http://maps.google.com/maps/api/js?sensor=false': 
this content should also be loaded over HTTPS. about:srcdoc:1

     Uncaught ReferenceError: google is not defined about:srcdoc:21

GET https://chamaoskurumi.shinyapps.io/TESTmapSHINY
           /_w_cf38cbc66a336eaf0ab8b4e184402cba949ec9bc0b5cc5c0/Legendf4d2427a4.png 
           404 (Not Found) about:srcdoc:3419

    Uncaught ReferenceError: google is not defined about:srcdoc:1989
    initializeabout:srcdoc:1989
    onloadabout:srcdoc:3411

1 个答案:

答案 0 :(得分:0)

shinyapps论坛上有人解决了我的问题。 http需要在地图文件中替换为https。 Codewise,这意味着:

readLines('myMap1.html')

需要替换为

gsub("http://maps.google.com/", 
     "https://maps.google.com/", 
     readLines('myMap1.html'), 
     fixed=TRUE)

我还联系了作者,以便在plotGoogleMaps包的下一次更新中解决此问题。 请注意,图例不起作用,但似乎是another issue