Google static map API getting 403 forbidden when loading from img tag

enable the static maps api on google cloud
google.places.geocoding.http error
google static maps api java
google static maps api python
google static maps api marker icon
google maps static api multiple markers
google maps api static map satellite
google static maps without api key

What I have is a Google map that shows the location of a property but when I come to print the dynamic maps dont print so good so I decided to implement the Google Static Map image API.

http://lpoc.co.uk/properties-for-sale/property/oldgate-dairy-st-james-road-long-sutton-cambridgeshire-pe12/?prop-print=1

^^ is an example of a property in print view and should show a static map image but it fails to load and looking at my inspector I'm getting a 403 Forbiden response for the image.

But if I go to the URL directly the image loads...

What am I doing wrong?

Thanks

Scott

This has gotten quite a lot of views, so I'm adding my solution to the problem here:

When using the new API, make sure you generate a Key for browser apps (with referers) and also make sure the patterns match your URL.

E.g. when requesting from example.com your pattern should be

  example.com/*

When you're requesting from www.example.com:

  *.example.com/*

So make sure you check whether a subdomain is present and allow both patterns in the developer console.

  1. Visit the Developer Console.
  2. Under API Keys, click the pencil icon to edit.
  3. Under "Key restrictions", ensure that you have an entry for example.com/*, *.example.com/*, and any local testing domains you might want.

static maps return 403 forbidden when embedded in img tag, unless , Google static map API getting 403 forbidden when loading from img tag What I have is a Google map that shows the location of a property but when I come to  If I pu that url in the address bar of the browser directly, it works fine; however if I use it as the src attribute of an img tag, I get a 403 forbidden response. Everything is fixed if I include my api key (and use it on my domain, of course), that is:

There seems to be some confusion here, and since this thread is highly ranked on Google, it seems relevant to clarify.

Google has a couple of different API's to use for their maps service:

Javascript API

The old version of this API was version 2, which required a key. This version is deprecated, and it is recommended to upgrade to the newer version 3. Note that the documentation still states that you need a key for this to function, except if you're using "Google Maps API for Business".

Static Maps API

This is a whole different story. Static maps is a service that does not require any javascript. You simply call an url, and Google will return a maps image, making it possible to insert the URL directly into your <img> tag. The newest version is version 2, and this requires a key to function because a usage limit is applied.

A key can be requested here: https://code.google.com/apis/console

And the key should be added to the request for the correct image to be generated:

http://maps.googleapis.com/maps/api/staticmap?center=New+York,NY&zoom=13&size=600x300&key=API_console_key

I hope this clears up some confusion.

Error Messages | Maps Static API, I'm using the static maps api to get map images. Example url: http://maps.google.​com/staticmap?center=45.3898749 url in the address bar of the browser directly, it works fine; however if I use it as the src attribute of an img tag, I get a 403 forbidden response. Sign in to reply. Loading Sign in - Desktop. 403 FORBIDDEN: Errors that prevent a map from being displayed If you use the Maps Static API without an API key, or if billing is not enabled on your account, the

I had this same problem but my solution was different. I had the V2 maps api enabled, but not the static maps api (I thought this was V2). I enabled the static maps api and it worked.

Static Maps not shown anylonger on new Server, the alt text, firebug gives me error message: "NetworkError: 403 Forbidden - http://maps.googleapis.com/maps/api/staticmap?center=Albany  4 Google static map API getting 403 forbidden when loading from img tag Dec 11 '12 3 Can't phpize or configure an extension in OS X 10.9 Mavericks Feb 3 '14 3 Setting up unit testing in the Zend Framework Aug 20 '12

Oops I feel like such an idiot. I was using the old V2 maps API URL and not the new V3 API URL. I was getting a 403 because I was using the V2 URL without providing an API key :(

Formidable api 403, I'm trieing to access the JIRA Rest API like documented I always get a HTTP 403 Google static map API getting 403 forbidden when loading from img tag I was  14 Google static map API getting 403 forbidden when loading from img tag Jan 11 '13 14 Handlebars.js: Use a partial like it was a normal, full template Jan 16 '14 12 Getting META description via jQuery Jan 31 '12

Be hundred percent sure of these points: (for static maps)

  1. Enable your project at this url :

https://console.developers.google.com/apis/api/static_maps_backend/overview?project=

  1. You have your localhost, staging and production - all urls with wildcards enabled in the referrer section.

  2. Google has changed its policy and you now need an api key to display maps. refer this for more : Google Maps API without key?

Hope it helps.

Static Map Image Doesn't Show - 403 Forbidden [#1489042 , I have been struggling to get the static image to show. Several Chrome says that the server (their server) is forbidding the image. Here's what Chrome said, "​Failed to load resource: the server responded with a. Firebug is telling me: "​NetworkError: 403 Forbidden - http://maps.google.com/staticmap?"  22 Google static map API getting 403 forbidden when loading from img tag Mar 1 '11 18 Stop link's :before content from being underlined by rule applied to the link Dec 16 '11 18 Commas within CSV Data Nov 8 '10

API Documentation, You can simply embed static map image within an <img> tag's src attribute. Usage. Requests can be sent to the following endpoint. GET https://maps.​locationiq. Can t load google maps image Did you get a Google API key number? ¿Ha tenido un número API Google? Did you enable the "Static Maps API" and the "Elevation API"?

Forbidden 403 for js file on localhost?, Anyway, I've looked all over google and the site and none of the solutions I've localhost site, I'm getting this error when I use "Inspect Element" on Chrome: Failed to load resource: the server responded with a status of 403 (Forbidden) <script type="text/javascript" src="js/jquery.min.js"></script> <script  22 Google static map API getting 403 forbidden when loading from img tag 19 Stop link's :before content from being underlined by rule applied to the link 18 Commas within CSV Data

javascript: Google Staticmap 403 error, while using staticmaps I always get Failed to load resource: the server <img src​="https://maps.googleapis.com/maps/api/staticmap?center=  The Maps Static API developers guide is intended for website and mobile developers who want to include Maps Static API images within a webpage or mobile application. It provides an introduction to using the API and reference material on the available parameters. Except as otherwise noted, the content of this page is licensed under the

Comments
  • This is exactly what helped me! I spent whole weekend with that issue. Newest static maps api, right URL, I am sending api_key, api console told me "no problems" - and I was getting only error 403 forbidden by Google. Finally I found your advice and bingo! :) I've just added mydomain.com/* to api console and it works like a charm! Thank you :)
  • Also remember to add localhost/* if you want it to work on localhost
  • Is it possible to edit a project in the developer console, or do you have to delete the current one and add another?
  • I was eventually able to edit a project, but only from this URL: console.developers.google.com/apis/credentials/key
  • I dunno if this has changed since your answer, but according to the static maps API v2 a key is not required. quoted from the site: "Note that the use of a key is not required, though it is recommended. Examples in this document do not include the key parameter so that they will work for all users who cut-and-paste the code."
  • This worked for me. In the Google APIs console I had enabled "Google Maps API" but not "Static Maps API", which is near the bottom of the list.
  • But even so, how comes that you get 403 when loading from an img tag, and it works when loading directly in the browser?? I have the same issue
  • And by the way, what V3 api url???? According to the documentation, there no such a thing as a static map api V3, the latest version for static map api is V2. I'm confused
  • What do you mean by "the referrer section"? As best I can tell, a "project" consists of only a name - there's nothing in the UI to tie a project to a particular website.
  • Update: "the referrer section" is located under "Credentials", and you can only enter specific domains (with wildcards) once you add "Key restriction" via "HTTP referrers (web sites)"
  • I know this answer is old but future readers note that the linked doc states "This document details the Maps Static API v2". It also suggests that a key must be provided: &key=YOUR_API_KEY.