何时需要 Google 地图 API 密钥?
最近,Google 更改了其使用 API 密钥的政策。您现在应该不再需要 API 密钥来将 Google 地图放置在您的网站上。
这非常有效。但现在我在本地主机上运行了这个地图(没有 API 密钥),它工作得很好。但当我将其放到网上时,我会收到一个弹出窗口,提示我需要另一个 API 密钥。在该网站的另一个页面上,谷歌地图确实可以使用。这可能与无法使用的地图上有很多(30+)标记有关吗?
实际上,使用 API 密钥对我来说并不是一个很好的解决方案,因为这是许多网站上使用的 Wordpress 插件的一部分。
Recently Google changed it's policy on the use API keys. You're now supposed to no longer need an API key to place Google Maps on your website.
And this worked perfectly. But now I have this map (without API key) running on my localhost, which works fine. But as soon as I place it online, I get a popup saying that I need another API key. And on another page on that website, Google Maps does work. Could it maybe have something to do with that the map that doesn't work have a lot (30+) of markers on it?
Actually using an API key wouldn't be a very nice solution to me, as this is part of a Wordpress plugin used on many websites.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
听起来你正在运行 v2~ 是时候升级了,或者获取你想要运行它的域的密钥:
Google 地图 V2 API 密钥请求
Sounds like you're running v2~ time to upgrade, or get a key for the domain you want to run it on:
Google Maps V2 API Key Request
您不需要 API 密钥即可使用 Goolge Maps API V3。然而,我们刚刚遇到了一个问题,即 Google 报告我们已经超出了限制,即使我们没有(开发服务器)。我继续设置了一个 API 密钥,这实际上是有益的,因为您随后可以获得使用情况报告。此外,从那时起我们就没有看到错误的配额使用问题。我想我应该继续分享这个过程:
转到https://console.developers.google.com/
点击红色“创建项目”按钮
为您的项目命名,Google 将自动为其提供 ID
等待,直到底部的 Spinny 表示您的项目已完成。
在左侧导航栏中,选择 APIs 和 API 下的 API。进行身份验证,然后选择“Google Maps JavaScript API v3”
单击链接,然后打开 API
转至 API 和 API 下的凭证身份验证部分,然后单击公共 API 访问部分下的红色“创建新密钥”。然后单击浏览器密钥。
确保您的网站名称中包含星号。例如,使用 mywebsite.com/*。这将确保所有页面都有权使用该 API。
将密钥复制到 Google Maps API 的 Javascript 引用中,如下所示:
长话短说,密钥不是必需的,但最佳实践表明您应该使用该密钥。
You do not need an API Key to use Goolge Maps API V3. However, we just experienced an issue where Google reported that we had exceeded our limit, even though we didn't (Development Server). I went ahead and set up an API Key, and its actually beneficial, because you then get usage reporting. Also, we haven't seen the false Quota usage problem since then. I thought I would go ahead a share the process:
Goto https://console.developers.google.com/
Click the red 'Create Project' button
Give your project a name and Google will automatically give it an ID
Wait until the Spinny on the bottom says your project is complete.
In the left hand nav, select APIs Under APIs & Auth, and select 'Google Maps JavaScript API v3'
Click the link and then Turn on the API
Go to Credentials under the APIs & Auth section, and click the red 'Create New Key' under the Public API access section. Then click Browser Key.
Make sure you include the star in your Website's name. For example, use mywebsite.com/*. This will ensure all pages are authorized to use the API.
Copy the key into your Javascript reference to the Google Maps API, like so:
Long story short, the key is not required, but best practices would indicate that you should use the key.