7

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

Community
  • 1
  • 1
h.l.m
  • 13,015
  • 22
  • 82
  • 169

1 Answers1

4

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"
    )
  })

})
Atilla Ozgur
  • 14,339
  • 3
  • 49
  • 69
  • Please control your www directory that html file exists. You may need to create www directory – Atilla Ozgur Nov 30 '14 at 08:03
  • I created the the www directory and checked that the file exists...but it just doesn't load – h.l.m Nov 30 '14 at 21:56
  • Use developer tools to inspect iframe and copy paste its values – Atilla Ozgur Nov 30 '14 at 22:04
  • Also try to open www/mymap1.html by double clicking in IE and report if it works – Atilla Ozgur Nov 30 '14 at 22:10
  • The myMap.html file can be loaded in IE no problem, just not when it is in an iframe....and I'm not too sure how to 'inspect iframe' to copy and paste its values... – h.l.m Nov 30 '14 at 23:19
  • If IE is giving you "Not found", you are not giving correct file name to src attribute. Please control your code. Better yet. please copy paste my code to a new file and try to run it – Atilla Ozgur Nov 30 '14 at 23:47