Question

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?

Was it helpful?

Solution 7

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

OTHER TIPS

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=___">
</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&v=2&sensor=false&key=___">
</script>

and the error went away.

I was having the same problem and it turned that i was doing 2 calls to the http://www.google.com/jsapi url. The first one for adsense (without the key parameter) and then the second one for google maps with the key. Pretty stupid mistake but the result is that the although you put the key on the second call it doesn't use it.

I was getting the same problem and when i look at src part i found that my querystring part of src is wrong.

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

I clearly typed wrong querystring part. &\amp;&hl=en; I put & to wrong place. Then i changed my wrong syntax with a correct one

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

And voila it worked.

Google Maps APi not working in Firefox and IE but working in Chrome and Safari

CSS-Bug

Hi everyone, this is slightly off-topic, but since it cost me a whole day to figure this out i want to share it.

I had the above mentioned problem. The maps would load but except for the google log and terms of use, the map was just grey. SOLUTION

somewhere in a parent css i had following cod:

#content * {
    max-width: 100%;                      
}

removing it solved the problem;

hope this helps

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.

I've been fighting key issues for the last couple of hours. Was working on localhost, but not on my local network address or a domain name. I solved the issue by changing v=2 to v=2.x. I haven't tried 2.s. Also adding alert(window.location.host) for both my localhost address and domain name to a Browser Key in google's api console for maps v2.

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;
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;v=2&amp;key=ABQ...BlaBlaBla...cVw"
    type="text/javascript" />
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top