【问题标题】:.html plotGoogleMap does not load in shiny App when deployed on shinyapps.io.html plotGoogleMap 在shinyapps.io 上部署时不会加载到闪亮的应用程序中
【发布时间】:2014-07-31 07:33:40
【问题描述】:

我正在尝试将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

【问题讨论】:

    标签: r shiny plotgooglemaps


    【解决方案1】:

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

    readLines('myMap1.html')
    

    需要替换为

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

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

    【讨论】:

      猜你喜欢
      • 2019-04-24
      • 1970-01-01
      • 2019-04-20
      • 2018-02-03
      • 2017-09-05
      • 2020-09-30
      • 2020-03-12
      • 2021-03-26
      • 2020-08-29
      相关资源
      最近更新 更多