本地主机的 Googlemaps API 密钥 [英] Googlemaps API Key for Localhost

查看:27
本文介绍了本地主机的 Googlemaps API 密钥的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何让 Google Maps API 密钥在本地主机上工作?

How do I get Google Maps API key to work on localhost?

我创建了一个 API 密钥,并在引用下添加了以下内容:

I've created an API key and under referrers I add the following:

Accept requests from these HTTP referrers (websites) (Optional)

Use asterisks for wildcards. If you leave this blank, requests will be 
accepted from any referrer. Be sure to add referrers before using this key 
in production. 

localhost

这不起作用,如果我排除 API 密钥,它也不起作用.

This doesn't work and if I exclude the API key it doesn't work, either.

推荐答案

  1. 转到此地址:https://console.developers.google.com/apis
  2. 创建新项目并创建凭据(API 密钥)
  3. 点击图书馆"
  4. 点击您想要的任何 API
  5. 点击启用"
  6. 点击凭据";>编辑键"
  7. 在应用程序限制"下,选择HTTP 引荐来源网址(网站)"
  8. 在网站限制"下,点击添加项目"
  9. 在文本字段中输入您的网站地址(或localhost"、127.0.0.1"、localhost:port"等用于本地测试),然后按 ENTER 进行添加到列表
  10. 保存并在项目中使用您的密钥

这篇关于本地主机的 Googlemaps API 密钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆