Rus*_*sty 11 android whitelist google-maps-api-3 cordova
我在使用两个真正的Android手机上正确显示地图时遇到了一些问题 - 一个运行2.2.2,另一个运行4.2.2.后者在地图方面总是给我一些悲伤.我把它放在另一个线程中,因为我已经部分解决了它.
注意:我正在使用Phonegap Build with Dreamweaver CS6.只是一个没有清单xml文件的config.xml.
现在我有另一个问题,我必须将所有域列入白名单,以便地图在4.2.2上正常运行,我不知道为什么.最初我在config.xml中有这个:
<access origin="*.googleapis.com" />
<access origin="*.gstatic.com" />
<access origin="*.google.com" />
<access origin="maps.googleapis.com" />
<access origin="maps.gstatic.com" />
<access origin="mt0.googleapis.com" />
<access origin="mt1.googleapis.com" />
<access origin="csi.gstatic.com" />
Run Code Online (Sandbox Code Playgroud)
虽然这对于Android 2.2.2非常有效,但我会在4.2.2上遇到以下问题:
通过将所有内容列入白名单,所有这些问题都消失了.但是我不想将所有内容列入白名单,所以如果我在这里遗漏了什么,有谁知道吗?
任何帮助非常感谢.
编辑:据我所知,使用*.googleapis.com我还会包含类似的其余白名单域.但是我在搜索中已经注意到几次iOS要求明确列出域名.虽然目前这可能不适用,但我确实打算在iOS上使用这个应用程序,所以我把它留在了(除非有人可以告诉我它完全没用而且不需要;-).
////////更新1 ////////
通过Chrome开发人员工具上的网络选项卡,我提取了谷歌地图访问的所有网址.通过明确地说明它们中的每一个,一切正常如下:
<access origin="https://mts.googleapis.com" subdomains="true"/>
<access origin="https://mts0.googleapis.com" subdomains="true"/>
<access origin="https://mts1.googleapis.com" subdomains="true"/>
<access origin="https://maps.googleapis.com" subdomains="true"/>
<access origin="https://fonts.googleapis.com" subdomains="true"/>
<access origin="https://maps.gstatic.com" subdomains="true"/>
<access origin="https://csi.gstatic.com" subdomains="true"/>
<access origin="https://themes.googleusercontent.com" subdomains="true"/>
Run Code Online (Sandbox Code Playgroud)
这些可能会有所变化,所以如果我可以在每个域前面使用通配符*这将是好的,但这不起作用.我尝试了以下两种方法但没有成功:
<access origin="*.googleapis.com" subdomains="true"/>
<access origin="*.gstatic.com" subdomains="true"/>
<access origin="*.googleusercontent.com" subdomains="true"/>
<access origin="https://*.googleapis.com" subdomains="true"/>
<access origin="https://*.gstatic.com" subdomains="true"/>
<access origin="https://*.googleusercontent.com" subdomains="true"/>
Run Code Online (Sandbox Code Playgroud)
任何人都有任何想法,为什么我不能在这些情况下使用通配符?干杯.
////////更新2 /答案////////
经过多次实验,我找到了答案.看起来你必须非常具体地说明如何在config.xml中编写标签,特别是在允许子域时 - 显然指定子域不适用于通配符,所以你需要两个标签块.我终于使用https使用以下两个设备正常工作:
<access origin="*.google.com" />
<access origin="*.googleapis.com" />
<access origin="*.gstatic.com" />
<access origin="*.googleusercontent.com" />
<access origin="google.com" subdomains="true"/>
<access origin="googleapis.com" subdomains="true"/>
<access origin="gstatic.com" subdomains="true"/>
<access origin="googleusercontent.com" subdomains="true"/>
Run Code Online (Sandbox Code Playgroud)
希望这对某人有用.我仍然不明白为什么它在旧版Android上运行良好.如果有这样的感觉,也许有人可以帮助启发我?
白名单域的语法已随 PhoneGap 版本的不同而发生变化。如果您使用的是 3.1 或更高版本,请参阅此文档了解语法: http: //docs.phonegap.com/en/3.1.0/guide_appdev_whitelist_index.md.html。我想这可能就是你的通配符不适合你的原因。
我正在使用以下内容,它可以在我的 PhoneGap 应用程序中显示我的 Google 地图:
<access origin="*://*.googleapis.com/*" subdomains="true" />
<access origin="*://*.gstatic.com/*" subdomains="true" />
<access origin="*://*.google.com/*" subdomains="true" />
<access origin="*://*.googleusercontent.com/*" subdomains="true" />
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7222 次 |
| 最近记录: |