Google Maps API warning: NoApiKeys

匿名 (未验证) 提交于 2019-12-03 01:25:01

问题:

I've been using Google Maps API v3 for some time without an API key, and it worked well.
It still works, but I get a warning in the console:

Google Maps API warning: NoApiKeys https://developers.google.com/maps/documentation/javascript/error-messages#no-api-keys

I include the script the standard way:

And google.maps.version indicates that I'm using 3.24.2.

In the Google documentation I can only see the different ways to obtain a key, but there is no indication if it's required or not. I noticed the warning today and I'm quite sure it didn't appear a few weeks ago.

Everything is working fine for now, but I'm afraid that maps access without an API key will be ceased in the future. I'm reluctant to register for a key if I don't absolutely need to.

Should I worry about it?

回答1:

Creating and using the key is the way to go. The usage is free until your application reaches 25.000 calls per day on 90 consecutive days.

BTW.: In the google Developer documentation it says you shall add the api key as option {key:yourKey} when calling the API to create new instances. This however doesn't shush the console warning. You have to add the key as a parameter when including the api.

Get the key here: GoogleApiKey Generation site



回答2:

A key currently still is not required ("required" in the meaning "it will not work without"), but I think there is a good reason for the warning.

But in the documentation you may read now : "All JavaScript API applications require authentication."

I'm sure that it's planned for the future , that Javascript API Applications will not work without a key(as it has been in V2).

You better use a key when you want to be sure that your application will still work in 1 or 2 years.



回答3:

I had the same problem and I found out that if you add the URL param ?v=3 you won't get the warning message anymore:

Reproduction online

As pointed out in the comments by @Zia Ul Rehman Mughal

Turns out specifying this means you are referring to old frozen version 3.0 not the latest version. Frozen old versions are not updated with bug fixes or anything. But this is good to mention though. https://developers.google.com/maps/documentation/javascript/versions#the-frozen-version

Update 07-Jun-2016

This solution doesn't work anymore.



回答4:

Google maps requires an API key for new projects since june 2016. For more information take a look at the Google Developers Blog. Also more information in german you'll find at this blog post from the clickstorm Blog.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!