【发布时间】:2017-06-12 11:12:44
【问题描述】:
我正在尝试将包含 ArcGIS Online 地图的 iframe 容器嵌入到 Shiny 应用程序中。在本地运行时,以下server.r 文件中的网址按预期工作,但是,当我通过运行deployApp("appName") 将其部署到网络时得到一个空框:
ui.r:
library(shiny)
shinyUI(
fluidPage(
mainPanel(
tabsetPanel(
type="tabs",
tabPanel("Arc",
br(),
htmlOutput("arcFrame")
)
)
)
)
)
server.r:
library(shiny)
shinyServer(
function(input, output) {
output$arcFrame <- renderUI({
map <- tags$iframe(src="http://arcg.is/2jwKdHm",
height=600,
width=500)
print(map)
})
}
)
ArcGIS 提供以下 html 用于将此地图嵌入网站:
<style>.embed-container {position: relative; padding-bottom: 80%; height: 0; max-width: 100%;} .embed-container iframe, .embed-container object, .embed-container iframe{position: absolute; top: 0; left: 0; width: 100%; height: 100%;} small{position: absolute; z-index: 40; bottom: 0; margin-bottom: -15px;}</style><div class="embed-container"><iframe width="500" height="400" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" title="provPrepTest" src="//charlotte.maps.arcgis.com/apps/Embed/index.html?webmap=19da1da27f8a4a6ea508bdd9b10e44a4&extent=-80.7557,35.1872,-80.6,35.3118&zoom=true&scale=true&disable_scroll=true&theme=light"></iframe></div>
如果我将上述 server.r 文件中的 src="http://arcg.is/2jwKdHm" 换成 src="//charlotte.maps.arcgis.com/apps/Embed/index.html?webmap=19da1da27f8a4a6ea508bdd9b10e44a4&amp;extent=-80.7825,35.1246,-80.5669,35.3738&amp;zoom=true&amp;scale=true&amp;disable_scroll=true&amp;theme=light",那么我会得到一个底图、负载和本地,并确实部署到 Web。但是,它没有容器功能(例如,工具、切换层的能力、地址搜索)。
我没有运气将上面的 ArcGIS html 转换为可以通过 Shiny 使用工具等正确呈现容器的标签。任何帮助或建议将不胜感激。
【问题讨论】:
-
为什么是
src="//charlotte[etc]而不是src="http://charlotte[etc]? -
那来自上面的嵌入文本,以
<style>.embed-开头。即,为在其他地方嵌入地图而给出的特定文本包括没有 http 的 src。 -
你试过
http并得到同样的结果吗? -
是的,它的作用完全相同。它加载基本地图,但不传递
<style>.embed-container {position.....和<div class="embed-container">参数,容器和工具不会像src="http://arcg.is/2jwKdHm"那样加载。 (同样,后者只能在本地工作,不能部署)。
标签: html r iframe shiny arcgis