与cordova一起使用Google Map JavaScript库 [英] Using Google Map JavaScript library with cordova
问题描述
我也尝试在开发者控制台上提供此网址,但没有成功。
我试图提供通配符星号
是否有其他方式设置自定义引荐来源或如何解决此问题?
---编辑---
键,我更改为Android API键现在它工作正常。
cordova的值不正确: https://maps.googleapis.com/maps/api/js?key=<browser api key> ;
适合科尔多瓦的价值: https://maps.googleapis.com/maps/ap i / js?key =< android api key>
浏览器API键似乎只在html页面在http url
截至2017年5月,该问题已由Google解决。现在你可以使用file:/ referrer与API密钥。您可以在文档中看到以下文本:
file://引用者需要将特殊表示添加到键限制中。在添加到密钥限制之前,file:/部分应该替换为__file_url__。例如,file:// path / to /应格式化为__file_url __ / path / to / *。在启用file:// referers后,建议您定期检查您的使用情况,以确保它符合您的期望
https://developers.google.com/maps/documentation/javascript/ get-api-key#键限制
I am trying to use Google map JavaScript API with a cordova project,
I am getting the map, after few seconds, I am getting RefererNotAllowedMapError for file:///android_asset/www/index.html
I tried to provide this URL on the developer console also, but no luck.
I tried to provide wild card asterisk symbol
Is there any other way to set a custom referrer or how to solve this?
---EDIT---
I was using Browser API key, I changed to Android API key now it works fine.
Wrong Value for cordova: https://maps.googleapis.com/maps/api/js?key=<browser api key>
Proper Value for cordova: https://maps.googleapis.com/maps/api/js?key=<android api key>
Browser API key seems to be only allowed when the html page is executed on a http url
As of May 2017, the issue has been solved by Google. Now you can use file:/ referrers with API keys. You can see the following text in the documentation
file:// referers need a special representation to be added to the Key restriction. The "file:/" part should be replaced with "__file_url__" before being added to the Key restriction. For example, "file://path/to/" should be formatted as "__file_url__/path/to/*". After enabling file:// referers, it is recommended you regularly check your usage, to make sure it matches your expectations
https://developers.google.com/maps/documentation/javascript/get-api-key#key-restrictions
这篇关于与cordova一起使用Google Map JavaScript库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!