I am getting error
Google has disabled use of the Maps API for this application. The provided key is not a valid Google API Key, or it is not authorized for the Google Maps Javascript API v3 on this site. If you are the owner of this application, you can learn about obtaining a valid key here: https://developers.google.com/maps/documentation/javascript/tutorial#Obtaining_Key
I have generated an API from api-console and using it for my local/local-host website but each time I am getting the above error. How can I show google maps on my localserver?
To get an API key: Go to the Google Cloud Console. Click the project drop-down and select or create the project for which you want to add an API key. Click the menu button and select APIs & Services > Credentials.
Go to the Google Maps Platform > Credentials page. Select the API key that you want to set a restriction on. The API key property page appears. To accept requests from the list of website that you supply, select HTTP referrers (web sites) from the list of Application restrictions.
There is a clue in Google API’s error message – the API is fine, but the use and restrictions are incorrect. In your key restrictions, select the IP address (it may be IPv4 or IPv6) and Selected API: Places API. Sometimes Google will tell you which IP address to use (from what it sees making the request).
To ensure that your API key only accepts signed requests: Go to the Google Maps Platform Quotas page in the Cloud Console. Click the project drop-down and select the same project you used when you created the API key for the Maps Static API. Click the APIs drop-down and select Maps Static API.
I have the similar problem as you today and I think I solved it.
First I am assuming that you have a google map api key already. I think what you need to do is to to go API Console - Google Code and click on API access
on the left. You can see your api key and just below the key, Referers:
shows your allowed referers. What you need to do is click Edit allowed referers...
and then add
localhost/*
to allowed referers.
I am using a MAMP to host my html, and I monitor the request my browser sent to google for api and I get this header:
showing Referer as localhost/*
It takes several minutes for Google to process after you changed your Referer but it works fine for me afterwords.
The answer by @Fei helped me. The issue I ran into is including multiple referrals. The following worked well for me. Enter a return before adding each record (as opposed to a comma or another delimiter).
don't know if this is the same problem but for me it turned out to be not the referrer. I changed the url for map.google.com to the url below and the referrer as either "any referrer allowed" or one of the whitelisted patterns https://developers.google.com/console/help/#whitelistingbyhost.
I Removed the version and the file params from the url (even if the version was 3 it was still going through a v2 authorization)
<script src="http://maps.google.com/maps?sensor=false&key=${YOUR_KEY}" type="text/javascript"></script>
By what people say you would not need the key but could not get it working without it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With