【问题标题】:Google Places Autocomplete API Over Limit SolutionsGoogle Places Autocomplete API Over Limit 解决方案
【发布时间】:2017-08-03 17:02:34
【问题描述】:

我收到此错误:“您已超出此 API 的每日请求配额。”

目前,表单设置为强制从 API 中选择第一个匹配项。 超过此每日限制时,我不想强​​制选择第一场比赛。我认为状态 =“OVER_QUERY_LIMIT”会起作用,但事实证明这是我得到的状态 =“ZERO_RESULTS”。

有人知道为什么返回“ZERO_RESULTS”而不是“OVER_QUERY_LIMIT”吗?

这是我的一段代码:

geocoder.geocode({"address": firstResult}, function (results, status) {

                    if (status == google.maps.GeocoderStatus.OK) {
                            var formattedResult = results[0].formatted_address;
                            $("#input-location").val(formattedResult);
                        }
                    }
                    if (status == "OVER_QUERY_LIMIT") {
                        $(".btn-search-submit").removeAttr('disabled');
                        return;
                    }
                    if (status == 'ZERO_RESULTS') {
                        $(".search-no-results").remove();
                        $(".btn-search-submit").attr('disabled', true);
                        $(".pac-container").show();
                        $(".pac-container").append(
                                "<div class='search-no-results'>" +
                                "<p><strong> Sorry, no results</strong></p>" +
                                "<p>Please check your spelling or try a zipcode</p>" +
                                "</div>");

                        setTimeout(function(){
                            $(".pac-container").hide();
                        }, 3000);
                    }
                });
            }

【问题讨论】:

    标签: javascript google-maps-api-3 google-places-api geocoding


    【解决方案1】:

    这听起来更像是一个商业/软件工程问题,而不是编程问题。

    您可以在此处查看 Google Maps API 请求的费用:https://developers.google.com/maps/premium/usage-limits#limitexceeded

    您可以在此处查看可用的定价计划:https://developers.google.com/maps/pricing-and-plans/#details

    如果您超出限制,可能是时候升级定价计划了。

    【讨论】:

    • 感谢鲁道夫的回复。我正在登记升级 - 但为了安全起见,我想知道如何捕获此错误并切换表单的行为,以便它不会“强制”选择第一个选项。你知道为什么我不能获取“OVER_QUERY_LIMIT”状态吗?状态码返回为“ZERO_RESULTS”
    • 本地没见过;但有人在 GIS StackExchange 上有答案:gis.stackexchange.com/a/15365
    猜你喜欢
    • 2018-11-09
    • 2012-09-07
    • 2017-06-12
    • 2017-08-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-23
    • 2018-12-30
    相关资源
    最近更新 更多