2014-11-25 51 views
7

我想要在Internet Explorer和Google Chrome中使用Shiny時使用Shiny獲得plotGoogleMaps,並且想知道我需要做些什麼來修復它。閃亮的plotGoogleMaps Internet Explorer與Chrome

我使用的代碼使用的答案,不同的question

代碼工作在Chrome瀏覽器中,但是當IE是瀏覽器不能正常工作。

要重複的代碼在這裏再次是:

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

鑑於所創建的文件,我想這可能是一個加載的問題。

一如往常的任何幫助,將不勝感激

+0

是否使用的是IE瀏覽器的版本? – 2014-11-25 17:19:05

+0

我正在使用Internet Explorer 10 – 2014-11-25 17:28:46

+0

@ h.l.m您是否檢查了我的最新解決方案? – 2014-12-04 21:11:02

回答

4

你的問題不是R,有光澤或plotGoogleMaps,但IE瀏覽器支持HTML5標準。 對srcdoc的IE支持不好,請從這裏讀取link。您可以使用polyfill來支持IE,但我不認爲這是必要的,因爲您已經在plotGoogleMaps步驟中創建了必要的html文件。

請嘗試下面的代碼。代替iframe srcdoc,我使用src屬性。此外谷歌地圖html是在www目錄中創建的,所以閃亮將能夠看到它。我在IE 11中工作。我認爲它應該在IE10中工作。

我改變了我對普通閃亮應用解決方案的回答,因爲看起來單個文件應用也有問題。這是鏈接到shinyapps。另請參閱modern.ie screenshots和全部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" 
    ) 
    }) 

}) 
+0

謝謝你,但它似乎並沒有工作......它說「沒有發現」...... – 2014-11-29 23:44:08

+0

請控制你的www目錄該HTML文件存在。您可能需要創建www目錄 – 2014-11-30 08:03:31

+0

我創建了www目錄並檢查了該文件是否存在...但它只是不加載 – 2014-11-30 21:56:20