用于文件:///的Google Maps API密钥引荐来源

加里·辛普森

我遇到了一个应用程序,该应用程序部署了可以在三个不同位置显示的Google Map:

  • 在应用程序Webview中
  • 在浏览器中预览
  • 发布到服务器

因此,我需要用户在其中的API密钥上添加一些引荐来源网址,以在它们发布到自己的服务器时覆盖它们。

他们可以为自己服务器上已发布的地图以及本地浏览器中的预览添加适当的引荐来源网址。

但是,当在应用程序Web视图中预览地图时,我无法弄清楚您添加了什么作为引荐来源网址,并且此时页面的网址是file:///引用网址?

如果我们将完整的通配符api密钥的所有引荐来源都留空,则它将在应用程序的webview中起作用。

我已经尝试了尽可能多的配置,可以为file:/// url提供引荐来源网址,但没有运气:

我试过了:

文件

文件*

文件/*

文件:///*

Noogui

似乎您无法将其file:///用作URL来源来解决此问题您将始终收到RefererNotAllowedMapError错误。使用file:///作为URL的来源可以告诉我您正在尝试在本地环境中运行它。我建议您使用使用Python Simple HTTP服务器NodeJS本地服务器的本地服务器

我已经列举了有关如何在此SO线程中设置本地Python服务器的步骤您将可以使用它来运行您的Google Map示例。

更新

好消息,Google已添加对file:/引荐来源网址的支持。您可以在文档中看到以下文本

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

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

为什么Google Maps API密钥无法识别我的引荐来源网址?

来自分类Dev

Google Maps Geocoding的API密钥

来自分类Dev

Google Maps API密钥错误

来自分类Dev

google maps api,提供的API密钥无效

来自分类Dev

从 config.json 文件提供 google maps api 密钥

来自分类Dev

Google Maps SDK无法验证API密钥

来自分类Dev

动态设置GMLib的Google Maps Api密钥

来自分类Dev

没有密钥的Google Maps API?

来自分类Dev

Wordpress ACF Google Maps Field API密钥

来自分类Dev

无法获取Google Maps JavaScript API密钥

来自分类Dev

难以获取Google Maps的API密钥

来自分类Dev

隐藏Google Maps密钥

来自分类Dev

Google Maps API密钥不适用于所有环境

来自分类Dev

Google Maps API 限制适用于密钥还是云项目?

来自分类Dev

用于地理编码的Maps API密钥不再起作用?

来自分类Dev

用于地理编码的Maps API密钥不起作用

来自分类Dev

要使用Google Maps API,需要哪个API密钥?

来自分类Dev

如何在Google Map API中为本地主机提供引荐来源网址?

来自分类Dev

Google Maps API RefererNotAllowedError

来自分类Dev

Google Maps API DeletedApiProjectMapError

来自分类Dev

Google Maps Api许可

来自分类Dev

Google Maps Api

来自分类Dev

Google Maps REST API

来自分类Dev

Google Maps API请求

来自分类Dev

Google Maps Directions API

来自分类Dev

Google Maps API参数

来自分类Dev

适用于企业的Google Maps Mobile SDK与Google Maps Android API

来自分类Dev

Google Maps API v3导航(例如适用于Android的Google Maps)

来自分类Dev

适用于企业的Google Maps Mobile SDK与Google Maps Android API