简体   繁体   English

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

[英]The Google Maps API server rejected your request

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/console the API key seems to be all correct. 我已经检查了https://code.google.com/apis/console上的API访问权限,API密钥似乎都是正确的。 Just wondering how to fix the site and IP bit? 只是想知道如何修复网站和IP位?

See below the settings in google API console 请参阅以下google API控制台中的设置

在此输入图像描述

除“Google Maps API”外,请确保您已启用“Static Maps API”服务。

Make sure you have enabled the Google Maps related Services ("Google Maps Embed API" and "Static Maps API") like bellow: 确保您已启用与Google地图相关的服务 (“Google Maps Embed API”和“Static Maps API”),如下所示:

在此输入图像描述

And then mark them: 然后标记它们:

在此输入图像描述

In the new layout you find it here: 在新的布局中,您可以在此处找到它:

在此输入图像描述

当我启用“Google Maps Embed API”和“Static Maps API”时,它适用于我

确保在Simple API Access部分中有一个Browser键,并确保Referers设置为Any referer allowed

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 = [yourproject]

It will enable your map instantly. 它会立即启用您的地图。

I had the same issue. 我遇到过同样的问题。 I used this instead of this and 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. 还建议使用https而不是http。 This way your users wont get cert warnings if they view the page over SSL 这样,如果用户通过SSL查看页面,您的用户就不会收到证书警告

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。

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

From june 2018 you have to configure a billing account to continue using Maps static API; 从2018年6月起,您必须配置结算帐户才能继续使用Maps静态API; google "donate" 200$/day of credit Maps Static API Usage and Billing 谷歌“捐赠”200美元/天的信用额度静态API使用和计费

add key in the url is not enough 在网址中添加密钥是不够的

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 有关文档的更多信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM