iPhone/iPad谷歌地图嵌入框架

10

我有一个嵌入在iframe中的Google地图。就像这样:

<iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" 
marginwidth="0" src="http://maps.google.de/?ie=UTF8&amp;ll=51.151786,10.415039&
amp;spn=23.5119,51.723633&amp;t=h&amp;z=5&amp;output=embed"></iframe>

在浏览器中这很好,但 iPhone / iPad 尝试加载应用程序。这似乎工作得很好(我自己没有一个),但页面会加载,用户会收到一个弹出消息询问他是否要运行该应用程序。是否有一种方法只在 iframe 中显示地图?


有趣的问题。我从未见过这样的网站。它似乎总是加载一个应用程序。虽然我不太经常使用我的 iPhone 的网络浏览器... - Aurum Aquila
2个回答

7
我认为最简单的方法是直接使用Google Maps API来加载Google地图。
我最近遇到了这个问题,我在这篇教程中找到了非常完整和有用的代码。

你能详细解释一下吗?我的网站联系我们页面上有一个谷歌地图,根据谷歌地图提供的代码嵌入。但在 iPhone 上无法使用。点击“查看更大的地图”或类似的选项会带我进入谷歌地图应用程序,它可以正常工作,但网站上的地图则显示为空白,并显示以下文本:“登录,在移动设备中查看 | 经典版,(c) 2012 - 隐私,正在加载...”,其中选择了“移动设备”,而“正在加载...”则有一个永远旋转的图标。 - Xonatron
很遗憾,我认为人们首先会使用嵌入方法,因为这比使用API要容易得多。 - sam

-1

我猜在HTML/iFrame中加载Google地图的方法不正确...

我也很感兴趣,这是我使用“苹果iWeb”小部件谷歌地图的方式(在iFrame中运行良好):这是一款低成本软件...

这是我的HTML代码在“myGoogleMap.html”中(在清理了所有未使用的HTML后):

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="it" lang="it">
  <head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

    <meta name="iWeb-Build" content="local-build-20110308" />
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
    <meta name="viewport" content="width=700" />
    <title>Testo
</title>
    <link rel="stylesheet" type="text/css" media="screen,print" href="Vuoto_files/Vuoto.css" />
    <!--[if lt IE 8]><link rel='stylesheet' type='text/css' media='screen,print' href='Vuoto_files/VuotoIE.css'/><![endif]-->
    <!--[if gte IE 8]><link rel='stylesheet' type='text/css' media='screen,print' href='Media/IE8.css'/><![endif]-->
    <script type="text/javascript" src="Scripts/iWebSite.js"></script>
    <script type="text/javascript" src="Scripts/Widgets/SharedResources/WidgetCommon.js"></script>
    <script type="text/javascript" src="Scripts/Widgets/GoogleMap/GoogleMap.js"></script>
    <script type="text/javascript" src="Vuoto_files/Vuoto.js"></script>
  </head>
<body style="background: rgb(0, 0, 0) margin: 0pt; " onload="onPageLoad();" onunload="onPageUnload();">

    <div class="com-apple-iweb-widget-GoogleMap aboveStrokesAndFrames" id="widget1"
   style="height: 400px; left: 0px; opacity: 1.00; position: absolute; top: 0px; width: 320px; z-index: 1; ">
    </div>

    <script type="text/javascript"><!--//--><![CDATA[//><!--
new GoogleMap('widget1', 'Scripts/Widgets/GoogleMap', 'Scripts/Widgets/SharedResources', '.', {"language": "it", "showInfo": "0", "locatedAddressIsFromGeocoder": "1", "unlocatedAddress": "", "zoomLevel": "6", "center": "51.261915,10.151367", "locatedAddressPoint": "19.56661,-99.134932", "locatedAddress": "my address in Mexico, Pico de Orizaba 3A, Lomas de Cuautepec, Delegazione Gustavo A. Madero, Cittá del Messico, Distrito Federal, Messico", "showGoogleBar": "1", "showMarker": "1", "showZoom": "1"});
//--><!]]>
    </script>
</body>
</html>

然后我在另一个 HTML 中使用以下代码加载它:

<iframe width="320" height="400" frameborder="0" scrolling="no" marginheight="0" 
marginwidth="0" src="Sito-test/myGoogleMap.html">
</iframe>

当然,你也需要 iWeb 制作的 JavaScript,但我不确定是否合法向你展示它们...
总之,重点是现在你知道了可以在 iFrame 中加载它而无需出现“安装应用程序”的问题...

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接