Shiny plotGoogleMaps Internet Explorer vs Chrome

时间:2021-10-18 22:28:48

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.

我正在尝试使用Shiny在Internet Explorer和Google Chrome中工作时使用plotGoogleMaps,并且想知道我需要做些什么来修复它。

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.

当Chrome是浏览器时,代码可以正常工作,但当IE是浏览器时,代码不起作用。

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

一如往常,任何帮助将不胜感激

1 个解决方案

#1


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.

你的问题不是R,有光泽或plotGoogleMaps,但IE支持html5标准。 IE对srcdoc的支持不好,请从此链接中读取。您可以使用polyfill来支持IE,但我认为没有必要,因为您已经在plotGoogleMaps步骤中创建了必要的html文件。

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.

请尝试以下代码。我没有给iframe srcdoc,而是使用src属性。此外,谷歌地图html是在www目录中创建的,以便闪亮的将能够看到它。我在IE 11中工作了。我认为它应该在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.

我改变了我对普通闪亮应用解决方案的回答,因为看起来单个文件应用程序也存在问题。这是与shinyapps的链接。另请参阅modern.ie截图和所有IE屏幕截图。

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

})

#1


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.

你的问题不是R,有光泽或plotGoogleMaps,但IE支持html5标准。 IE对srcdoc的支持不好,请从此链接中读取。您可以使用polyfill来支持IE,但我认为没有必要,因为您已经在plotGoogleMaps步骤中创建了必要的html文件。

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.

请尝试以下代码。我没有给iframe srcdoc,而是使用src属性。此外,谷歌地图html是在www目录中创建的,以便闪亮的将能够看到它。我在IE 11中工作了。我认为它应该在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.

我改变了我对普通闪亮应用解决方案的回答,因为看起来单个文件应用程序也存在问题。这是与shinyapps的链接。另请参阅modern.ie截图和所有IE屏幕截图。

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

})