Google 地点 API Return 邮政编码

Google Places API Return Postcode

我正在尝试获取返回的 Google 个地点的邮政编码 API。

我到处都看过,但似乎找不到人们如何做的工作示例。

这是我的 API,它在 Postman 中运行良好:

https://maps.googleapis.com/maps/api/place/autocomplete/json?input=Sydney&region=AU&key=xxxxx&libraries=places

这是示例 JSON 响应

{
   "predictions": [
      {
         "description": "xxxxx",
         "place_id": "xxx",
         "reference": "xxx",
         "structured_formatting": {
            "main_text": "xxx",
            "main_text_matched_substrings": [
               {
                  "length": 2,
                  "offset": 0
               },
   ],
   "status": "OK"
}

如何获取邮政编码详细信息?

没关系,找到解决方案了。

需要使用另一个 API 端点并像这样插入 place_id:

https://maps.googleapis.com/maps/api/place/details/json?region=AU&key=xxx&place_id=xxxx