google-maps - Cordova 谷歌地图 key API错误

标签 google-maps google-maps-api-3

我有一个带有 cordova 的跨平台应用程序,但现在谷歌地图无法工作。 我有这个错误:

MissingKeyMapError 

我尝试在 Google 控制台中使用“*”授权 url 创建新的 api 浏览器 key ,但仍然无法正常工作。我有这个错误:RefererNotAllowedMapError 我的应用程序的window.location.href是:file:///Users/bahri/Library/Developer/CoreSimulator/Devices/757EE924-9884-44B1-B‌​BF5-04CFF3D68C80/data/Containers/Bundle/Application/820BF808- DFF7-4AB0-8BF8-179D2‌​78E90D5/com.taxiwink.taxiwinkapp.app/www/index.html

如何解决这个问题?

最佳答案

截至今天(2020 年 7 月 15 日),以下 http 引荐来源网址允许在 cordova 应用程序中显示 Google map :

iOS:

__file_url__//var/containers/Bundle/Application/*
__file_url__//private/var/containers/Bundle/Application/*

(感谢 yannisalexiou 添加了适用于 iOS13 的最后一个)

安卓:

__file_url__//android_asset/www/index.html#/*
__file_url__//android_asset/www/index.html

cordova 模拟(例如:模拟 ios --target=chrome)

127.0.0.1
localhost

引荐来源网址进入 Google Console API 管理(API 项目、凭据、引荐来源网址):

https://console.cloud.google.com/apis/credentials/key/abcxyz?project=api-project-123456

注意:根据 https://github.com/wevote/WeVoteCordova/issues/55 的答案开发

关于google-maps - Cordova 谷歌地图 key API错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37992487/

相关文章:

google-maps - 仅通过 GET 参数围绕某个位置创建一个圆圈

javascript - PHP MySQL 中的地理编码动态标记

javascript - Google Map API - 如何更改标记上的默认光标

google-maps - 调整 google.maps.Circle 半径更准确

google-maps - 使用Google Map Tracks API

php - 如何组合功能以获取多种类型的信息

google-maps - 没有图钉/图标的 map

javascript - 谷歌地图作为我的 Canvas 绘图的背景

javascript - Google Places API 中 "places search box"的事件是什么?

javascript - Google map 通过我的标记进行搜索