Why has my Google Maps API key become invalid?

2019-04-12 12:10发布

问题:

It's my first question here and I didn't found an answer in my research.

I've got a probleme with my google map API key, on a old site (not mine). tao-yin.com ( French associations of Qiqong). There's 2 months, i did a map for this website (in 2 places).

Here : http://www.tao-yin.com/arts_classiques_tao/liste_associations.html

and here : http://www.tao-yin.com/pratique-qi-gong/Cours_stages.htm

Everything was ok, for a while. It's a map with Accessing Arguments in UI Events. Now, I learned that, (as you can see it) the 2 map are out because the key is invalid. The English error message:

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#Obtaining_Key

I'm suprised. Why is the key no longer valid but was ok before ? I read that the v2 is not more valid since the 19 may, but it's a v3key (activatedd). And for the code (i'm not an expert) I took an exemple for v3 on the internet.

  1. I tried to change the key and erase the old : same problem
  2. I tried 2 key ( one for map) : same problem
  3. I tried to change the code javascript with a another one ( a google example) : same problem
  4. I tried to make a better html code : same probleme

I don't know what happened. I think i break a rule , but wich one ? It's for a friend, for an association. It's for free.

Somebody have an idea ?

I don't not what to do: how can i put a googlemap on this website ? I read that it's possible directly with googlemap and an iframe, but i need specific event. Not just an address.

回答1:

I found the solution, it's very simple:

the problem was in the declaration of the website in the API key.

In the windows of declaration we have this exemple to followon the bottom.

Example: .example.com/.

But, here : https://developers.google.com/console/help/?hl=fr#restrictingusage URL Pattern : the good choice. It's logic.

Before i had : ".tao-yin.com/" and it was working (so i don't ask more) but it's not logic because its not on a subdomains.

Now everything is ok with : "www.tao-yin.com"

So : don't follow the example of Google ;-) juste follow the instruction. Thank's to everybody.



回答2:

Google Maps keys are tied to the referring URL hostname. You may wish to get yourself a key for development; they are free.

It's possible, but unlikely, that they have killed your friend's key because his site was very busy and was generating more than the allowable map requests. I don't think they kill the keys in this case, but rather just refuse the requests.



回答3:

This link also helps. It shows a table of which google mapping products/APIs and the associated keys needed to use them:

https://developers.google.com/maps/faq#keysystem