javascript Google Maps API 服务器拒绝了您的请求

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19408066/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 15:29:38  来源:igfitidea点击:

The Google Maps API server rejected your request

javascriptgoogle-mapsgoogle-maps-api-3

提问by rumi

I m working on an application which renders google maps on an image as below

我正在开发一个应用程序,它在图像上呈现谷歌地图,如下所示

<img alt="Google Maps (Scotland)" src="http://maps.google.com/staticmap?size=480x200&amp;maptype=mobile\&amp;markers=55.9368450758,-3.03604939504,reda|55.9454374538,-3.18124534297,redb&amp;key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx">

The map is not getting rendered and when I right click on the source of image and click the url, I get the following message

地图未呈现,当我右键单击图像源并单击 url 时,我收到以下消息

"The Google Maps API server rejected your request. This site or IP is not authorized to use this API key."

“Google Maps API 服务器拒绝了您的请求。此站点或 IP 无权使用此 API 密钥。”

I have checked the API Access on https://code.google.com/apis/consolethe API key seems to be all correct. Just wondering how to fix the site and IP bit?

我已经检查了https://code.google.com/apis/console上的 API 访问API 密钥似乎都是正确的。只是想知道如何修复站点和 IP 位?

See below the settings in google API console

请参阅下面的 google API 控制台中的设置

enter image description here

在此处输入图片说明

回答by Simon Perepelitsa

Make sure you have enabled "Static Maps API" service in addition to "Google Maps API".

确保除了“Google Maps API”之外,您还启用了“Static Maps API”服务。

回答by eusoubrasileiro

Make sure you have enabled the Google Mapsrelated Services("Google Maps Embed API" and "Static Maps API") like bellow:

确保您已启用Google Maps相关服务(“Google Maps Embed API”和“Static Maps API”),如下所示:

enter image description here

在此处输入图片说明

And then mark them:

然后标记它们:

enter image description here

在此处输入图片说明

In the new layout you find it here:

在新布局中,您可以在这里找到它:

enter image description here

在此处输入图片说明

回答by Anh Hoang

It works for me when I enable "Google Maps Embed API" and "Static Maps API"

当我启用“Google Maps Embed API”和“Static Maps API”时它对我有用

回答by Plato

Make sure you have a Browser key in the Simple API Access section, and make sure the Referersis set to Any referer allowed

确保在 Simple API Access 部分有一个浏览器密钥,并确保Referers设置为Any referer allowed

回答by Karthik SWOT

Activate Google Map Key here: https://console.developers.google.com/apis/api/maps_embed_backend/overview?project=[your-project]

在此处激活 Google 地图密钥:https: //console.developers.google.com/apis/api/maps_embed_backend/overview?project=[your-project]

It will enable your map instantly.

它将立即启用您的地图。

回答by Matt Evans

I had the same issue. I used thisinstead of thisand that resolved the issue. Some other api parameters didn't work on the second URL either (specifically marker styles), guessing the old API is deprecated

我遇到过同样的问题。我用这个代替这个,解决了这个问题。其他一些 api 参数也不适用于第二个 URL(特别是标记样式),猜测旧 API 已弃用

Would also recommend using https as opposed to http. This way your users wont get cert warnings if they view the page over SSL

还建议使用 https 而不是 http。这样您的用户在通过 SSL 查看页面时不会收到证书警告

回答by Alex Chen

Not only you need to enable google static API, but also you need to include your api_key in the link.

您不仅需要启用 google 静态 API,还需要在链接中包含您的 api_key。

enable static mapinclude your api key

启用静态地图包括您的 api 密钥

回答by gbutta

From june 2018 you have to configure a billing account to continue using Maps static API; google "donate" 200$/day of credit Maps Static API Usage and Billing

从 2018 年 6 月起,您必须配置计费帐户才能继续使用 Maps 静态 API;谷歌“捐赠”200 美元/天的信用 地图静态 API 使用和计费

add key in the url is not enough

在 url 中添加 key 是不够的

回答by Soldeplata Saketos

As commented by Pointy, you need to use an API key with all referrers allowed in order to use Static Maps.

正如Pointy评论的那样,您需要使用 API 密钥并允许所有引用者才能使用静态地图。

You can achieve that just by removing all the referrers from the list of authorized referrers. Or just create a new API key and use it without further configuration.

您可以通过从授权推荐人列表中删除所有推荐人来实现这一点。或者只是创建一个新的 API 密钥并使用它而无需进一步配置。

More info at the Documentation

文档中的更多信息