【发布时间】:2016-05-04 02:58:53
【问题描述】:
我正在尝试制作一个简单的地理定位应用程序。本地地理定位在坐标输入时工作正常。我很难加载谷歌地图,like in the Simple Markers example here。
Turns out you have to whitelist external domains。没问题,我在 config.xml 中添加了以下内容(在 phonegap 应用程序的根目录中):
<access origin="*" />
<access origin="*://*.googleapis.com/*" subdomains="true" />
<access origin="*://*.gstatic.com/*" subdomains="true" />
<access origin="*://*.google.com/*" subdomains="true" />
<access origin="*://*.googleusercontent.com/*" subdomains="true" />
以防万一,我在<platform name="android"> 下添加了相同的内容。然后我删除了它。依然没有。
然后我让应用显示一个简单的图像;这是应用程序的 HTML 部分的样子:
<body>
<span><img src="https://maps.gstatic.com/mapfiles/api-3/images/spotlight-poi_hdpi.png" alt="" /></span>
<div id="map"></div>
</body>
如果我在浏览器中打开这个文件,没关系:
但是当我编译应用程序并在我的平板电脑上打开它时,呃哦:
所以看起来访问权限设置不正确。图片坏了,googleapis.com 永远不会加载,我的地图永远也看不到曙光。
我的根 config.xml 文件的Here is a pastebin。
请帮我弄清楚为什么 android 应用拒绝在 PhoneGap/Cordova 的上下文中加载外部 url。
我赌的是一些我不知道的晦涩的权限。我的头撞墙有一段时间了,真的很感激一些帮助。提前致谢。
【问题讨论】:
标签: javascript android cordova google-maps phonegap-build