将 Google Map JavaScript 库与 cordova 一起使用

Using Google Map JavaScript library with cordova

本文关键字:一起 cordova 库与 Google Map JavaScript      更新时间:2023-09-26

我正在尝试将Google map JavaScript API与Cordova项目一起使用,

正在获得地图,几秒钟后,我得到了RefererNotAllowedMapError file:///android_asset/www/index.html

我也尝试在开发人员控制台上提供此URL,但没有运气。

我尝试提供通配符星号符号

有没有其他方法可以设置自定义引荐来源网址或如何解决此问题?

---编辑---

我正在使用浏览器 API 密钥,我更改为 Android API 密钥,现在它可以正常工作。

科尔多瓦的错误值:https://maps.googleapis.com/maps/api/js?key=<浏览器 api=" 密钥=">

科尔多瓦的正确值:https://maps.googleapis.com/maps/api/js?key=

浏览器 API 密钥似乎仅在 http 网址上执行 html 页面时才允许

截至 2017 年 5 月,该问题已由 Google 解决。现在您可以使用文件:/带有 API 密钥的引荐来源网址。您可以在文档中看到以下文本

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