Google 地图反向编码 API 突然开始失败

Google Maps Reverse Coding API suddenly starts failing

在我的 React 本机应用程序中,我使用 Google 反向地理编码 API 从经纬度获取位置名称。几个月来一直很好用,现在突然开始失败了。

我使用的查询:

fetch("https://maps.googleapis.com/maps/api/geocode/json?address=" +
            this.state.region.latitude + "," +
            this.state.region.longitude +
            "&key=" + GOOGLE_API_KEY
    )
    .then(response => response.json())
    .then(responseJson => { ... })

我意识到我这几个月都在使用它,因为它应该是 .../json/latlng 而不是 .../json/address。所以我现在更正了它:

https://maps.googleapis.com/maps/api/geocode/json?latlng=....

Offical Docs

所述

它仍然没有给出任何结果,尽管状态为:200

下面是我从这个 fetch 电话中得到的回复,它没有给出任何可能出错的重要信息。

{
    "type": "default",
    "status": 200,
    "ok": true,
    "headers": {
        "map": {
            "content-type": "application/json; charset=UTF-8",
            "server-timing": "gfet4t7; dur=17",
            "pragma": "no-cache",
            "alt-svc": "h3-Q050=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000,h3-27=\":443\"; ma=2592000,h3-T051=\":443\"; ma=2592000,h3-T050=\":443\"; ma=2592000,h3-Q046=\":443\"; ma=2592000,h3-Q043=\":443\"; ma=2592000,quic=\":443\"; ma=2592000; v=\"46,43\"",
            "cache-control": "no-cache, must-revalidate",
            "server": "mafe",
            "expires": "Fri, 01 Jan 1990 00:00:00 GMT",
            "access-control-allow-origin": "*",
            "x-xss-protection": "0",
            "content-encoding": "gzip",
            "date": "Sun, 20 Sep 2020 15:01:41 GMT",
            "content-length": "200",
            "vary": "Accept-Language",
            "x-frame-options": "SAMEORIGIN"
        }
    },
    "url": "https://maps.googleapis.com/maps/api/geocode/json?latlng=12.991999943565116,77.72999983280897&key=XXXXXXXXXX",  // Instead of XXX there was correct key
    "bodyUsed": false,
    "_bodyInit": {
        "_data": {
            "size": 256,
            "offset": 0,
            "blobId": "2728F9A1-2861-4EDB-A9B7-1500F3F5205C",
            "type": "application/json",
            "name": "json",
            "__collector": {}
        }
    },
    "_bodyBlob": {
        "_data": {
            "size": 256,
            "offset": 0,
            "blobId": "2728F9A1-2861-4EDB-A9B7-1500F3F5205C",
            "type": "application/json",
            "name": "json",
            "__collector": {}
        }
    }
}

我尝试提供多个不同的 lat lng 对(它们之前工作),但它不再工作了。

我有一个有效的 Google 地图计费帐户,信用额度中已有几百美元。所以这也不是计费问题。


更新

当我将此查询放入浏览器时(正如@geocodezip 在评论中所建议的那样),它给出了与计费相关的错误响应:

{
   "error_message" : "You must enable Billing on the Google Cloud Project at https://console.cloud.google.com/project/_/billing/enable Learn more at https://developers.google.com/maps/gmp-get-started",
   "results" : [],
   "status" : "REQUEST_DENIED"
}

尽管已启用计费。我现在正在与 Google 云支持联系,以解决问题。

我与 Google 支持人员进行了交谈,他们告诉我 可能是 因为注册的结算帐户(用于 Google Cloud Platform)在由于印度移民,印度卢比及其不再与 Google 地图平台兼容。

https://developers.google.com/maps/gmp-india-faq#bill-why

而且我必须将我的(Google 云)项目计费帐户从 INR 更改为美元计费帐户。尽管我的 Google 地图计费帐户已经使用美元。

(是的,它们是不同的。Google Maps billing acc & Google Cloud Billing acc)

在没有任何警告邮件的情况下,Google地图突然暂停了地图API服务!!

在生产应用中使用地图 api 的人请多多关照。