【问题标题】:Why is the Google Places API is randomly returning "Not Authorized" errors?为什么 Google Places API 会随机返回“未授权”错误?
【发布时间】:2016-08-23 17:07:24
【问题描述】:

我在使用 google 地方 API 时得到了非常奇怪的结果。

我有以下非常简单的代码:

<!DOCTYPE html>
<html>
<body>
    <input id="pac-input" type="text" placeholder="Enter a location">
    <script>
        var initMap = function () {
            var autocomplete = new google.maps.places.Autocomplete(document.getElementById('pac-input'));
        }
    </script>
    <script src="https://maps.googleapis.com/maps/api/js?key=[MyKey]&libraries=places&callback=initMap"></script>
</body>
</html>

我发现它可以在大约前 10 次击键时工作,然后服务返回“此 API 项目无权使用此 API”。错误信息。

但是,当我在 Plunker 上运行相同的代码时,它一直都能完美运行。

这是我的本地主机的几个屏幕截图:

我启用了 Google Maps Geocoding API 和 Google Maps JavaScript API。

我在这里错过了什么?

【问题讨论】:

  • 是的,这很奇怪。我有同样的问题。仍在试图弄清楚一些事情。我讨厌处理不可重现的错误。

标签: google-places-api


【解决方案1】:

对我来说,除了启用“Google Maps JavaScript API”之外,还启用了“Google Places API Web Service”。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多