tags:

views:

3460

answers:

5

I'm having a problem with getting my Google Maps API key to work. I originally had the problem when trying to access http://dev.domain.com using a key generated for http://domain.com, however I subsequently tried generating a key for http://dev.domain.com and it still didn't work.

I get the typical This web site needs a different Google Maps API key. A new key can be generated at http://code.google.com/apis/maps/. alert message when trying the site. Checking their FAQ and following it's instructions to alert(window.location.host) to check the domain returns dev.domain.com which looks correct (unless it's meant to have http:// at the start? In which case I don't see how I've done something wrong).

Both keys (dev.domain.com and domain.com) work correctly on localhost.

Does anyone have any ideas on what I can do to solve this or any further tests I can do to work it out?

A: 

Hi, After going through their FAQ i found that if we want our subdomains to enable Google map we have to request the API for http://domain.com/ (without www) . it worked for me. Happy coding.

Praveen
Thanks, but I said that I had tried the key generated for http://domain.com and that also didn't work. I never worked out the reason for the problem, instead I just started using v3 of the API.
Blair McMillan
A: 

As said in my comment I ended up using the v3 API as this never ended up being solvable.

Blair McMillan
A: 

I had the same problem when I added line breaks to the src element for readability:

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

Removing the line breaks from the src element solved the problem:

<script src="http://maps.google.com/maps?file=api&amp;amp;v=2&amp;amp;key=ABQ...BlaBlaBla...cVw"
    type="text/javascript" />
Sorcha
You had a different problem actually.
mgamer
You also used a self closing tag, when you should've used an opening tag and a closing tag.
Simon Bartlett
+2  A: 

I came across this question as I was just now beating my head against this same issue. I finally noticed that the code Google provided for linking to the API was different from what I'd been using. I replaced this

<script type="text/javascript" src="http://www.google.com/jsapi?key=___"&gt;
</script>
<script type="text/javascript">
    google.load("maps", "2.x", { "language": "en" });
</script>

with this

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

and the error went away.

Herb Caudill
Notice that although this uses the V3 syntax for instantiating the api, it doesn't require you to upgrade from v2 to v3 - in my case the upgrade was breaking existing code that I didn't have time to go through and debug, so that was a big plus.
Herb Caudill
A: 

yes, use API V3 that solve my problems. thanks \blair-mcmillan

vietbv