40
votes

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

enter image description here

9
The source IP of the HTTP request will be the IP address of a client web browser, not your server. - Pointy
Ok - can you kindly explain a little bit what shall I try to correct here. Do I need to fix the site or add the correct referers. I've tried adding the "asteric.asteric" in the api consoles, allowed referers but that did not help either - rumi
I am getting the similar error as The Google Maps API server rejected your request. This service requires an API key. but if I opened same map URL in new browser tab map image load without any error. - Dipak Telangre

9 Answers

74
votes

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

21
votes

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

enter image description here

And then mark them:

enter image description here

In the new layout you find it here:

enter image description here

11
votes

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

5
votes

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

2
votes

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

1
votes

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

enable static map include your api key

1
votes

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

0
votes

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