Google Maps API key not working - google-maps

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?

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&v=2&&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&v=2&hl=en&key=MY_API_KEY&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.

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

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&
v=2&
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&v=2&key=ABQ...BlaBlaBla...cVw"
type="text/javascript" />

Related

Missing API Key in google maps

I have a Drupal theme whith a google maps. But the map is missing an api key, and when I open my Drupal page I see this.
I have a Drupal theme containing a gmap.js file.
Is it possible to change it there.
I tried writing api=API_KEY; of course I replaced API_KEY with my own key.
Do anyone know?
It's key=API_KEY.
This is an example from Google:
<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap"
async defer></script>

<Forge Viewer> Nothing is displayed by a browser.

A model was displayed normally until last week.
But Nothing is displayed by a Browser Today.
The following log is displayed to a Chrome-console.
GET viewer3D.min.js:4
https://developer.api.autodesk.com/derivativeservice/v2/manifest/<MyUrn>
401 (Unauthorized)
Was there the change of specifications about any OAuth or Derivative API?
Is there the method avoiding this error?
I used this as reference.
We have solved the problem by ourselves.
It was the bug of viewer3D.min.js(Ver2.11).
I changed Javascript URL.
<script src="https://developer.api.autodesk.com/viewingservice/v1/viewers/viewer3D.min.js"></script>
↓
<script src="https://developer.api.autodesk.com/viewingservice/v1/viewers/viewer3D.min.js?v=2.10.*"></script>
Thank you for All.

OpenLayers 2.13.1 with Google maps

When I switch from OpenLayers 2.12 to 2.13.1, all Google Maps layers stop working. When I use the layer switcher the map area just turns white.
I don't see any error messages in the development console of my browser at any point, and all files are loaded successfully.
I'm creating layers like this:
var layerGoogleMapsNormal = new OpenLayers.Layer.Google("Google Normal" , { type : google.maps.MapTypeId.ROADMAP, sphericalMercator : true });
var layerGoogleMapsPhysical = new OpenLayers.Layer.Google("Google Physical" , { type : google.maps.MapTypeId.TERRAIN, sphericalMercator : true });
Other layers (OSM, WMS) work fine.
While I was writing this, I found out that the example from OpenLayers doesn't work properly either.
http://dev.openlayers.org/examples/google.html
Could it be that Google made a breaking change?
Does anyone else have the same problem, and does anyone know a solution?
Remark:
I've looked at OpenLayers3, but its API is so different that I don't think we'll ever be able to port all of our code to that. We won't be able to convince our clients to pay for rewriting all of the mapping stuff to make use of OL3, so I guess this project is stuck with the 2.x branch forever...
I had the same problem as you.
In the link that includes the js file from Google, you must tell it to send you an older version, before the breaking change from 15 Sep.
Example:
Normal link: <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&sensor=false"></script>
Solution link: <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&sensor=false&v=3.20"></script>
At the moment, the latest version is 3.22. What works best for me is 3.20 for the same Openlayers version as yours.
More info on the topic:
https://developers.google.com/maps/documentation/javascript/versions
Later Edit: As the comments mention, this fix no longer works. In the github issue thread somebody did a patch fix, but I couldn't find the file for direct download so I had to manually apply the fix to my project. To save the others from doing the same, I'll put here a link to the minified version with the fix included.
Download: OpenLayers 2.13.1 with google fix
The accepted answer now no longer works since, as #geocodezip mentioned, v3.20 has now been retired by Google. In order to make OpenLayers 2.13.x work with the current version of the Google Maps API you must monkey patch the OpenLayers.js file as specified in this comment on OpenLayers issue #1450.

google map api v3 in app

I am creating an app that uses google map. i inserted the map api key inside the html page.
<script type="text/javascript" src="https://maps.googleapis.com/maps/api /js?key=AIzaSyDcvUkjiKRkJ2zV8cYElZy55JLZDjiL9g8&sensor=false"></script>
i keep getting error saying " Google has disabled use of the Maps API for this application. The provided key is not valid Google API key, or it is not authorized for google Maps Javascript API v3 on this site ". i just followed whatever they had mentioned in here
https://developers.google.com/maps/documentation/javascript/tutorial#api_key
i don't have any problem when run this code in my html. Only problem is that some of the map page don't render out properly. Which version is better to use V2 or V3 ?
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
i am kinda confused. Can someone help me out what i doing wrong or what do i need to do. Since my app is totally based google map. Thanks
I see two possibilities for you:
Either you use this line in your code <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=CHANGE_YOUR_KEY_HERE&sensor=false"></script> and you generate a new key for you application: https://developers.google.com/maps/documentation/javascript/tutorial#api_key
(on the screenshot you can see the link "Generate new key...")
Or you use this line without bothering with having a key. (for example: http://jsfiddle.net/LZmQ2/)

The provided key is not a valid Google API key Ext JS issue

I got some issue in Google Map api in my project. I didn't handled anything related to this part and it was working fine before today.
But now, If i run the application, i got this popup msg and after that, the pages that are using google map api aren't working with this error.
I googled and followed this step.
1) https://code.google.com/apis/console/b/0/#project:40595208241:access
2) generate a new key
3) copy the new key to the index.htm inside key value
<script src="http://maps.google.com/maps?file=api&v=2.x&key=AIzaSyAJz86xjTce_oqnSTw8MoNaY-13tIx03XU" type="text/javascript"> </script>
<script type="text/javascript" src="extJS-ux/GMapPanel.js"></script>
<link href="extJS-ux/Ext.ux.grid.RowActions.css" rel="stylesheet" type="text/css" />
<script src="http://www.google.com/jsapi?key=AIzaSyAJz86xjTce_oqnSTw8MoNaY-13tIx03XU" type="text/javascript"></script>
<script type="text/javascript">
google.load('search', '1');
</script>
So i've followed this same step, but now it doesn't work anymore. It doesn't show the error msg anymore, but it doesn't also show up the result. It says no result and do nothing. It worked right yesterday!!
I tried to do some other ways, but there wasn't a good solution for this.
Can you help me with this?
You are using v=2.x (the "experimental version). That is not recommended for production sites. It might start working if you call for v=2 or v=2.s (the "stable" version), if this was a change in the API.
Note that you are using v2 of the Google Maps API which is deprecated and may stop working May 19, 2013; definitely not recommended for production sites.