简体   繁体   English

为什么我使用cordova-plugin-googlemaps得到了空白地图

[英]Why have I got a blank map using cordova-plugin-googlemaps

i'm develop an hybrid app with cordova framework and jquery mobile. 我正在使用Cordova框架和jquery mobile开发一个混合应用程序。 I use cordova-plugin-googlemaps instead of google maps javascript api v3 to improve the performance of my app. 我使用cordova-plugin-googlemaps而不是google maps javascript API v3来提高我的应用程序的性能。 When I run my app on android device it displays a blank map. 当我在android设备上运行我的应用程序时,它会显示一个空白地图。 I use this tutorial [Tutorial for Windows to add cordova-plugin-googlemaps][1] 我使用本教程[Windows教程添加cordova-plugin-googlemaps] [1]

[1]: https://github.com/mapsplugin/cordova-plugin-googlemaps/wiki/Tutorial-for-Windows to add cordova plugin and this [Blank Map][2] [1]: https : //github.com/mapsplugin/cordova-plugin-googlemaps/wiki/Tutorial-for-Windows添加科尔多瓦插件和此[空白地图] [2]

[2]: https://github.com/mapsplugin/cordova-plugin-googlemaps/wiki/TroubleShooting:-Blank-Map to resolve my problem but i haven't solved. [2]: https : //github.com/mapsplugin/cordova-plugin-googlemaps/wiki/TroubleShooting : -Blank -Map解决了我的问题,但我还没有解决。 Help me, please! 请帮帮我!

ps: i'm sorry for my english ps:对不起我的英语

When you access any resources or assets not on the webpage you need to use a whitelist . 当您访问网页上没有的任何资源或资产时,您需要使用whitelist

The fix to many common white-list problems 解决许多常见的白名单问题

The alternative is this quick fix – but know that this quick fix removes all needs for white-list . 替代方法是此快速修复程序-但知道此快速修复程序消除了所有white-list需求。 This creates a security issue which you may not want to by pass. 这会创建一个安全问题 ,您可能不希望通过。

QUICK FIX Add this to your config.xml for PHONEGAP BUILD ONLY 快速修复将此添加到PHONEGAP BUILDconfig.xml
<preference name="phonegap-version" value="3.7.0" />

The long answer is as such: 长答案是这样的:

From Top Mistakes by Developers new to Cordova/Phonegap you have hit: Cordova / Phonegap的开发人员的最新失误中您可以找到:

  • #6 Not setting the "phonegap version" for your compiler #6 没有为编译器设置“ phonegap版本”
  • #7 Not setting "version" for you plugins #7 不为您的插件设置“版本”
  • #10 Not adding the new "white-list" and "white-list plugin" parameters in config.xml. #10 未在config.xml中添加新的“白名单”和“白名单插件”参数。

For #6 & #7 对于#6和#7

With the CLI version, if you do not assign a version for your platform OR in ''Phonegap Build'' if you do not set the phonegap-version in config.xml, YOU WILL GET THE LATEST VERSION. 使用CLI版本时,如果您未为平台分配版本,或者如果未在config.xml中设置phonegap-version,则在“ Phonegap Build”中分配了最新版本。 If you are lucky, your program just works as expected. 如果幸运的话,您的程序将按预期运行。 If you are not lucky, you'll get a set of cascading errors. 如果您不走运,则会出现一系列级联错误。

Luckily for all of us, Holly Schinsky has written a nice blog post to explain it all: 幸运的是,我们所有人Holly Schinsky都写了一篇不错的博客文章来解释这一切:

Cordova/PhoneGap Version Confusion Cordova / PhoneGap版本混乱
http://devgirl.org/2014/11/07/cordovaphonegap-version-confusion/ http://devgirl.org/2014/11/07/cordovaphonegap-version-confusion/

For #10 对于#10

This relatively * NEW * requirement means – to access ANY website or resources on the web, you MUST use the whitelist and the whitelist plugin. 这种相对*新*的要求意味着–要访问任何网站或Web资源,您必须使用白名单和白名单插件。 This requirement goes into affect, if you are using cordova-android@4.0.0 or better; 如果您使用的是cordova-android@4.0.0或更高版本,则此要求生效。 including cli-5.1.1 and cli-5.2.0. 包括cli-5.1.1和cli-5.2.0。 If however, your version is before 4.0.0, let's say 3.5.0 or 3.7.0, then you will not have to add the white-list requirement. 但是,如果您的版本低于4.0.0(例如3.5.0或3.7.0),那么您将不必添加白名单要求。

To be clear, the "whitelist" has been around for a bit, but the plugin and requirement is very new. 需要明确的是,“白名单”已经存在了一段时间,但是插件和要求是非常新的。 As you would expect, when the "whitelist" was added, the defacto open-access feature was deprecated. 如您所料,添加“白名单”后,事实上的开放式访问功能已被弃用。 Or said another way, the defacto open-access feature was planned and scheduled to be eliminated. 或者说另一种方式,事实上的开放式访问功能已被计划并计划取消。 This change marks a step in removal of the open-access feature. 此更改标志着取消了开放式访问功能的一步。

In addition, the Content Security Policy (CSP) has caught numerous developers - because it was soooo poorly publicized. 此外,内容安全政策(CSP)吸引了众多开发人员-因为它的宣传不力。 Depending on your use and the version of Phonegap you are using, the CSP needs to go in every single HTML page you used, just like you have to wait for 'deviceready'. 根据您的使用和使用的Phonegap的版本,CSP需要进入您使用的每个HTML页面,就像您必须等待“ deviceready”一样。 However, there are cases where it is not needed at all. 但是,在某些情况下根本不需要它。 The documentation is confusing for some, please read it carefully. 该文档有些令人困惑,请仔细阅读。 The documentation is buried in the bottom of many of the latest documentation pages. 该文档埋在许多最新文档页面的底部。

Lastly, Raymond Camden in his blog points to a LARGE change in policy starting with Cordova 5 最后,雷蒙德·卡姆登(Raymond Camden)在他的博客中指出, 从科尔多瓦5开始,政策发生巨大变化

Related Links 相关链接

Phonegap Build Forum: Notes for upgrading to cli-5.1.1 on PGB and now required Whitelist Phonegap Build论坛: 在PGB上升级到cli-5.1.1的注意事项 ,现在需要白名单

Although this is old question, but some people still access from this page. 尽管这是一个古老的问题,但是仍然有人可以从该页面访问。 I update this answer. 我更新了这个答案。

JesseMonroy650's answer is mis-leading. JesseMonroy650的答案具有误导性。 Because the original questioner describes "he/she uses cordova-plugin-googlemaps instead of google maps javascript api v3" . 因为原始发问者描述为“他/她使用cordova-plugin-googlemaps而不是google maps javascript api v3”

cordova-plugin-googlemaps is a wrapper plugin of "Google Maps SDK for Android" and "Google Maps SDK for iOS" at 2015. cordova-plugin-googlemaps是2015年的“ Android版Google Maps SDK”和“ iOS版Google Maps SDK”的包装插件。

"cordova-plugin-googlemaps" provides original JavaScript API of those native SDKs. “ cordova-plugin-googlemaps”提供了这些本地SDK的原始JavaScript API。 But in the behind, the plugin manipulate native APIs, and those native APIs do not follow the white-list rules at all, because it's not JavaScript. 但是在后面,该插件会操纵本机API,而这些本机API完全不遵循white-list规则,因为它不是JavaScript。


Many people ask me "Why I get blank map?" 许多人问我“为什么我得到空白地图?”

There are two reasons: 有两个原因:

1) If you mean "blank map" is "gray map", then it's your API key authentication problem. 1)如果您的意思是“空白图”是“灰色图”,那么这就是您的API密钥身份验证问题。 Most people are this case. 大多数人都是这种情况。

https://github.com/mapsplugin/cordova-plugin-googlemaps-doc/blob/master/troubleshootings/graymap/README.md https://github.com/mapsplugin/cordova-plugin-googlemaps-doc/blob/master/troubleshootings/graymap/README.md

2) If you mean "white map" (you can not see the map at all), probably you hide the map with background-color or some another DOM. 2)如果您指的是“白色地图”(根本看不到地图),则可能是用background-color或其他DOM隐藏了地图。

Because the maps plugin displays native Google Maps View under browser view . 因为地图插件会在浏览器视图下显示本机Google Maps View。

3) Even if you can't solve your problem, please ask me at https://github.com/mapsplugin/cordova-plugin-googlemaps/issues 3)即使您不能解决问题,也请在https://github.com/mapsplugin/cordova-plugin-googlemaps/issues问我

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Play 商店中的 Cordova-plugin-googlemaps 空白屏幕 - Cordova-plugin-googlemaps blank screen on Play store 地图拖动事件谷歌地图android sdk cordova cordova-plugin-googlemaps - map drag event google maps android sdk cordova cordova-plugin-googlemaps 使用Cordova插件通过WayPoints从源到目的地的路线添加了cordova-plugin-googlemaps - Directions from Source to Destinations via WayPoints using cordova plugin add cordova-plugin-googlemaps 离子插件添加cordova-plugin-googlemaps后构建失败 - BUILD FAILED after ionic plugin add cordova-plugin-googlemaps 当我尝试使用以下科尔多瓦google maps插件https://github.com/mapsplugin/cordova-plugin-googlemaps时出现错误 - I am getting an error when I tried to use the following cordova google maps plugin https://github.com/mapsplugin/cordova-plugin-googlemaps cordova-plugin-googlemaps如何从标记数组触发标记的info_window - cordova-plugin-googlemaps how to trigger the info_window of marker from marker array Gradle“ com.android.dex.DexException”构建了一个涉及cordova-plugin-googlemaps和ibm-mfp-push插件的应用程序。 - Gradle “com.android.dex.DexException” building an app involving cordova-plugin-googlemaps and ibm-mfp-push plugins. 使用谷歌地图插件与科尔多瓦显示空白地图 - using google map plugin with cordova show blank map 重复点击Cordova Googlemaps插件 - Repeated clicks on Cordova Googlemaps plugin 在Android模拟器中使用Cordova Google Maps插件时出错:GoogleMaps插件中未定义getMap - Error using Cordova Google Maps plugin in android emulator: getMap is not defined in GoogleMaps plugin
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM