javascript - 谷歌地图API被禁用?

标签 javascript html api google-maps google-api

我有这个简单的代码:

<html>
 <script type="text/javascript"
        src="http://maps.googleapis.com/maps/api/js?key=AIzaSyBSB4gQMtgeyqNvwmORpW1rY_3wFYjGS9E&sensor=false">
    </script>
</html>

当我在本地运行它时,几秒钟后,它会弹出一条警告:

"Google has disabled the use of Maps API for this application. See the Terms of Service for more information..."

这是我通过创建“新浏览器 key ”创建的新 key ,并且“允许任何引荐来源网址”。我以前从未使用过 Google Maps API,并且我没有做任何违反 Google TOS 的事情,让他们禁用我的许可证。

我的帐户是否有问题,因此它会自动禁用我传递给它的任何 key ?我如何检查我的帐户是否有任何“保留”?

如果许可证是我的问题,我可以在没有许可证的情况下使用 google api 吗?

我仍在寻找为什么我无法使用上面的简单代码片段来加载谷歌地图 API 的答案。这真的不应该这么困难。我陷入了什么样的困境或陷阱?我可以做哪些研究来帮助我解决这个问题?

最佳答案

注册您的网址(复制自 https://developers.google.com/maps/documentation/business/clientside/auth ):

In order to prevent a third party from reusing your client ID on their own website, the use of your client ID is restricted to a list of URLs that you specifically authorize.

To obtain a list of your authorized URLs, or to authorize additional URLs:

  1. Log in to the Google Enterprise Support Portal.
  2. From the left side menu, click Maps: Manage Client ID.

You may add up to 100 URLs at a time, to a total of 3000 URLs. If you require higher limits, please contact Google Enterprise Support.

The following considerations apply regarding URLs that are authorized:

The domain name or IP address does not have to be publicly accessible. For example, http://myintranet and http://192.168.1.1 are valid entries.

All subdomains of a specified domain are also authorized For example, if http://example.com is authorized, then http://www.example.com is also authorized. The reverse is not true; if http://www.example.com is authorized, http://example.com is not.

All subpaths of an authorized path are also authorized. For example, if http://example.com is authorized, then http://example.com/foo is also authorized. In addition, because subdomains of a specified domain are also authorized, http://sub.example.com/bar is authorized.

Paths are case-sensitive. For example, http://www.example.com/ThisPath/ is not the same as http://www.example.com/thispath/.

You may restrict valid URLs to those using certain ports. For example, if http://example.com:8080/foo is specified, http://example.com is not.

HTTP and HTTPS protocols are considered different URLs. For example, if https://example.com is authorized, http://example.com is not. If you'd like to authorize both at once, you may add a domain without using a protocol: example.com/

All of the rules above are applied to each authorization, so you should take care to plan your authorizations carefully. For example, because all subpaths of a specified path are authorized, and all subdomains, you may end up authorizing pages that you didn't intend to. E.g:

http://example.com/ also authorizes http://sub.example.com/path.

关于javascript - 谷歌地图API被禁用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22901014/

相关文章:

javascript - ie9中的黄色警告图标在哪里

javascript - CSS 样式和 Jscript 未在 MS Outlook 2007 中正确反射(reflect)

api - 如何直接从我的服务器将视频上传到 Youtube?

c# - 根据以下场景,分配线程最有效的方法是什么?

angularjs - 如何在 Angular JS 中取消挂起的 API 调用

javascript - 未找到该相关模块:

javascript - 延迟加载下一页 fullpage.js 不起作用

javascript - jQuery sum TD 点击事件

html - 表格行宽 100% 不尊重 parent

javascript - jquery 麻烦——将字符串添加到动态命名的元素