简体   繁体   中英

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

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

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

See below the settings in google API console

在此输入图像描述

除“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:

在此输入图像描述

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]

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

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

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

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

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

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.

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.

More info at the Documentation

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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