Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Maps API Key alert

Tags:

google-maps

I have a problem with my Google Maps API key. I get an alert saying "This web site needs a different Google Maps API key." When I prees OK to the alert the map are loading and working fine.

The same problem is already posted: Google Maps API key not working

I have tried to request the API key for both "http://www.domain.com" and "http://domain.com" but I still get the alert. When I follow the instructions from their FQA and use alert(window.location.host) I get www.domain.com but the api key generator will only accept the domain if the prefix is http://

Does anyone have a solution to this?

like image 230
taudorf Avatar asked Mar 18 '10 12:03

taudorf


People also ask

Is API key for Google Maps free?

Note that the Maps Embed API, Maps SDK for Android, and Maps SDK for iOS currently have no usage limits and are at no charge (usage of the API or SDKs is not applied against your $200 monthly credit). Can I use the Google Cloud Platform $300 no charge trial with Google Maps Platform?

How do I get my Google map API key?

Go to the Google Maps Platform > Credentials page. On the Credentials page, click Create credentials > API key. The API key created dialog displays your newly created API key. Click Close.

Is Google Maps API key secret?

API keys are not strictly secret as they are often embedded into client side code or mobile applications that consume Google Cloud APIs. Still,they should be secured and should never be treated as public information.


2 Answers

I found out that is was a generel encoding error in my google maps api script tag. I got the alert error when I had a script tag like this:

<script src="http://maps.google.com/maps?file=api&amp;amp;v=2&amp;amp;key=MyGoogleMapsApiKey" type="text/javascript"></script>

The problem here is the duplicated amp;wich was generated from a scriptmanager in asp.net. So the & was replaced with &amp;.

The script tag should look like this:

<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=MyGoogleMapsApiKey" type="text/javascript"></script>

So if you are using a scriptmanager to add script tags or in any other way dynamically adding script tags to your pages, wach out for duplicated amp;.

like image 194
taudorf Avatar answered Nov 15 '22 09:11

taudorf


You have to sign up for the new google API key for your new domain, I used to get the same error message, because I use the old API with the new domain, please click the following link to register your new API key for the new domain.

http://code.google.com/apis/maps/signup.html

Hope this can help.

Vutha

like image 33
vuthaKH Avatar answered Nov 15 '22 09:11

vuthaKH