I am trying to embed a plotGoogleMap
in a shiny app online.
Locally the app works perfectly, but when uploading via shinyapps
to shinyapps.io the .html map does not load.
Any ideas how to solve this issue?
See my code below.
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"
)
})
})
deploy app with shinyapps
library('shinyapps')
setwd("~/working directory where ui.R and server.R are located locally")
deployApp()
This is the error log but I dont know what to conclude from it:
[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
Someone on the shinyapps Forum solved my issue. http
needs to be replaced by https
in the map file.
Codewise, this means that:
readLines('myMap1.html')
needs to be replaced by
gsub("http://maps.google.com/",
"https://maps.google.com/",
readLines('myMap1.html'),
fixed=TRUE)
I also contacted the author to fix this in the next update of the plotGoogleMaps
package.
Note that the legend does not function, but that seems to be another issue