Google Maps:为什么会出现referer-not-allowed-map-error? [英] Google Maps: why do I get referer-not-allowed-map-error?

查看:172
本文介绍了Google Maps:为什么会出现referer-not-allowed-map-error?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Android应用程序(在Play商店外),该应用程序使用带有HTML网页的Java脚本来调用Google Maps.将API创建为Android应用程序时得到referer-not-allowed-map-error.我需要将限制设置为NONE才能正常工作.该应用已通过调试正确签名.

I have an Android app (outside the Play Store) that uses a HTML page with a Javascript that calls Google Maps. I get a referer-not-allowed-map-error when creating the API as Android app. I need to set restrictions to NONE for this to work properly. The app is signed properly as debug.

这是为什么?如何限制API?

Why is this? How can I restrict the API?

推荐答案

Android应用限制对Google Maps JavaScript API无效.此限制仅与Google Maps Android SDK和Places Android SDK一起使用.

Android app restriction is not valid for Google Maps JavaScript API. This restriction is only used with Google Maps Android SDK and Places Android SDK.

请参阅以下文档,其中介绍了可以与Google Maps API一起使用的API密钥限制类型

Have a look at the following document that explains which type of API key restriction you can use with Google Maps APIs

https://developers.google.com/maps/faq#keysystem

为了解决您的问题,当您从Android应用程序的Web视图中加载window.location.href的值时,建议您在HTML页面中检查window.location.href的值.该值将包含可用作Maps JavaScript API的HTTP引荐来源网址限制的字符串.请注意,file://协议要求特殊表示,如

In order to solve your issue, I would suggest checking the value of window.location.href in your HTML page when you load it from Web view in your Android app. This value will contain string that might be used as HTTP referrer restriction for Maps JavaScript API. Note that file:// protocol requires special representation as explained in

https://developers.google.com/maps/documentation/javascript/get-api-key#key-restrictions

我希望这会有所帮助!

I hope this helps!

这篇关于Google Maps:为什么会出现referer-not-allowed-map-error?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆