42

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

imbr
  • 6,226
  • 4
  • 53
  • 65
rumi
  • 3,293
  • 12
  • 68
  • 109
  • The source IP of the HTTP request will be the IP address of a client web browser, not your server. – Pointy Oct 16 '13 at 16:00
  • 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 Oct 16 '13 at 16:08
  • 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 Apr 19 '17 at 13:41

9 Answers9

76

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

Simon Perepelitsa
  • 20,350
  • 8
  • 55
  • 74
  • 14
    For people like me who are using the embedded iFrames, you will need to enable the "Embed API" instead (Static is *not* needed if you're *only* embedding). – Bing Apr 29 '15 at 10:44
22

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

imbr
  • 6,226
  • 4
  • 53
  • 65
12

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

Anh Hoang
  • 2,242
  • 3
  • 22
  • 23
5

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

Plato
  • 10,812
  • 2
  • 41
  • 61
  • Do you mean set the allowed referers to asteric.asteric? – rumi Oct 16 '13 at 16:07
  • 2
    Next to my key, it says "Referers: Any referer allowed". and when I click 'Edit allowed referrers' the popup box is empty. so if you have specific domains (or `*.*`) in that box, remove them and click 'update' – Plato Oct 16 '13 at 16:14
  • Can you please see in the question now as I have uploaded the settings screenshot but still getting the same issue – rumi Oct 16 '13 at 21:22
  • Is your app using the obsolete key? Have you tried from a different machine, maybe google has blacklisted your current IP where you are testing the site from? It also sounds like Google Maps Business API users have different rules: https://developers.google.com/maps/documentation/business/articles/troubleshooting_auth – Plato Oct 16 '13 at 21:40
  • 1
    Thats a life saver of a comment, I had been putting the website in as the referrer not thinking it would be the client. – tristanbailey Oct 05 '14 at 12:55
4

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.

Karthik SWOT
  • 1,129
  • 1
  • 11
  • 15
2

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

Jagat Dave
  • 1,643
  • 3
  • 23
  • 30
Matt Evans
  • 7,113
  • 7
  • 32
  • 64
1

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

Alex Chen
  • 41
  • 2
1

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

gbutta
  • 11
  • 1
0

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

Community
  • 1
  • 1
Soldeplata Saketos
  • 3,212
  • 1
  • 25
  • 38