1

我正在尝试plotGoogleMap在线嵌入一个闪亮的应用程序。该应用程序在本地运行良好,但通过上传shinyapps到 shinyapps.io 时,.html 地图不会加载。

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


请参阅下面的代码。

用户界面

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

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

服务器.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
4

1 回答 1

0

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

readLines('myMap1.html')

需要替换为

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

我还联系了作者,以便在下次更新plotGoogleMaps包时解决这个问题。请注意,图例不起作用,但这似乎是另一个问题

于 2014-06-12T14:39:13.907 回答