Shiny plotGoogleMaps Internet Explorer vs Chrome
I am trying to get plotGoogleMaps when using Shiny working in Internet Explorer as well as Google Chrome, and was wondering what I need to do to fix it.
The code I am using uses the answer to a different question
The code works when Chrome is the browser, but doesn't work when IE is the browser.
To repeat the code again here it is:
library(plotGoogleMaps)
library(shiny)
runApp(list(
ui = pageWithSidebar(
headerPanel('Map'),
sidebarPanel(""),
mainPanel(uiOutput('mymap'))
),
server = 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 = "100%",
height = "600px"
)
})
}
))
Given that the file is created, I think it is probably a loading issue.
As always any help would be greatly appreciated
Your problem is not R, shiny or plotGoogleMaps, but IE support for html5 standard. IE support for srcdoc is not good, read from this link. You may use polyfill to support IE but I do not think it is necessary since you are already creating necessary html file in plotGoogleMaps step.
Try following code. Instead of giving iframe srcdoc , I use src property. Also google map html is created in www directory so that shiny will be able to see it. I made it work in IE 11. I think it should work in IE10.
I changed my answer to normal shiny app solution since it seems that single file applications has also a problem. This is link to shinyapps. And see also modern.ie screenshots and all IE screenshots here.
ui.R
library(plotGoogleMaps)
library(shiny)
shinyUI(fluidPage(
pageWithSidebar(
headerPanel('Map'),
sidebarPanel(""),
mainPanel(uiOutput('mymap'))
)
))
server.R
library(plotGoogleMaps)
library(shiny)
shinyServer(function(input, output) {
if (!file.exists("www"))
{
dir.create("www")
}
output$mymap <- renderUI({
data(meuse)
coordinates(meuse) = ~x+y
proj4string(meuse) <- CRS("+init=epsg:28992")
m <- plotGoogleMaps(meuse, filename = 'www/myMap1.html', openMap = F)
tags$iframe(
src = 'myMap1.html',
width = "100%",
height = "600px"
)
})
})
链接地址: http://www.djcxy.com/p/82628.html