Google Maps V3 API Key Invalid - but my personal d

2020-02-26 07:40发布

I've recently been doing development upgrading our maps to v3 and during development I was using my own personal key. Everything was working fine. When it was time to go to production I had someone generate a key through the company's google account and now it doesn't work. I've sat next to them making sure they were generating a browser key, and I'm pretty sure the domains are correct under the "Referrer's" section matching both: .mydomain.com/ mydomain.com/*

I've verified that we are using Key for browser apps.

I've verified that the Google Maps API v3 is turned ON via the services panel. Everything is identical to the way I was doing it with my key. I think the only difference is that they've enabled Billing on the company account where as my key doesn't. We'd like to get this moved off of my key seeing as how it's receiving more than the 25k views/day limit on my account.

When using the company API key the map loads and then very quickly I get an alert box which reads: "Google has disabled use of the Maps API for this application. The provided key is not a valid Google API Key, or it is not authorized for the Google Maps Javascript API v3 on this site. If you are the owner of this application, you can learn about obtaining a valid key here: https://developers.google.com/maps/documentation/javascript/tutorial#api_key"

If I then replace the key with my own key, with the same referrers settings, it works..

Any help would be greatly appreciated.

11条回答
手持菜刀,她持情操
2楼-- · 2020-02-26 08:12

If you are testing locally, make sure to add your local ip to the server key:

xxx.xxx.xxx.xxx

if you want the maps api to be available across the whole domain add this to the browser key:

*.mydomain.com/*

Hope this helps.

查看更多
Luminary・发光体
3楼-- · 2020-02-26 08:13

I had a number of reports from clients about problems with Google maps on their sites. I checked and got "Invalid key" errors.

Strangely, Google used to give out keys with a space before and after the API key. In the past, when I left the spaces off, the key broke. It was frustrating to remember to leave those spaces.

Now, I trim() my current API Key (with or without spaces) before submitting it to Google Maps and it works.

查看更多
欢心
4楼-- · 2020-02-26 08:14

You are missing the v=3 before your key={yourkey}

Like this:

maps.googleapis.com/maps/api/js?v=3&key={your key}&sensor=false
查看更多
我命由我不由天
5楼-- · 2020-02-26 08:19

Actually you want the Google Maps JavaScript API to be enabled instead of Google Maps API v3 because the former is what you are actually using here. The latter is now divided into iOS and Android BTW.

Also you need to add your reference into your server key.

If it is local, it should be something like:

localhost/*

查看更多
小情绪 Triste *
6楼-- · 2020-02-26 08:21

Add v=3; before your key.

maps.googleapis.com/maps/api/js?**v=3;**key={your key};sensor=false
查看更多
登录 后发表回答