tags:

views:

829

answers:

3

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: http://stackoverflow.com/questions/1803327/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?

A: 

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

vuthaKH
+3  A: 

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;amp;v=2&amp;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;amp;v=2&amp;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;.

taudorf
You should accept this answer, as it solves the problem stated in the question. Yes, I know it is your own. Happy birthday.
Sky Sanders
A: 

I had the same problem. I remembered that Google calls my Appspot app by a different name found in the Versions area of the App Engine Dashboard. I changed the name of the URL to the long version and the key started to work... e.g. LIVE URI... http://5.latest.myappname.appspot.com.

You'd think they could resolve their keys to their own app hosting service urls.

Regards, John

John Reilly