首页 > 解决方案 > Google Places API 返回邮政编码

问题描述

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

我到处寻找,但似乎找不到人们如何做到这一点的有效示例。

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

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"
}

我如何获得邮政编码的详细信息?

标签: c#jsonapigoogle-mapsgoogle-maps-api-3

解决方案


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

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

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

推荐阅读