0

Google 地方信息提供的某些地方信息不正确。例如,如果您在自动完成中键入塞伦盖蒂国家公园,您有:

{    "predictions" : [
  {
     "description" : "Serengeti National Park, Serengeti, Mara, Tanzania",
     "id" : "08bd9d4d10a2c77c36987c118a638ba8f75fb2f1",
     "matched_substrings" : [
        {
           "length" : 23,
           "offset" : 0
        }
     ],
     "reference" : "CkRAAAAAWmw4d0BvC9XVNF73sDnNPiQ841LRJ02RiaLxFonlOJmvmbP01nFpaJVfQVTa1lJScXHCOGtu9P83kUOYAd7f2xIQ_KqR0A_Sbhg8qvEEaIwlEBoU1dU8yFyfIhcZFfRNpdNGpacv6V8",
     "terms" : [
        {
           "offset" : 0,
           "value" : "Serengeti National Park"
        },
        {
           "offset" : 25,
           "value" : "Serengeti"
        },
        {
           "offset" : 36,
           "value" : "Mara"
        },
        {
           "offset" : 42,
           "value" : "Tanzania"
        }
     ],
     "types" : [ "establishment", "geocode" ]
  }    ],    "status" : "OK" }

没关系。注意描述:塞伦盖蒂国家公园,塞伦盖蒂,马拉,坦桑尼亚。但是,如果您访问 Google Places 详细信息,您将获得以下信息:

{
   "debug_info" : [],
   "html_attributions" : [],
   "result" : {
      "address_components" : [
         {
            "long_name" : "Serengeti",
            "short_name" : "Serengeti",
            "types" : [ "administrative_area_level_2", "political" ]
         },
         {
            "long_name" : "Mara",
            "short_name" : "Mara",
            "types" : [ "administrative_area_level_1", "political" ]
         },
         {
            "long_name" : "TZ",
            "short_name" : "TZ",
            "types" : [ "country", "political" ]
         }
      ],
      "formatted_address" : "Tanzania",
      "geometry" : {
         "location" : {
            "lat" : -2.333333,
            "lng" : 34.833333
         }
      },
      "icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
      "id" : "08bd9d4d10a2c77c36987c118a638ba8f75fb2f1",
      "name" : "Serengeti National Park",
...
   },
   "status" : "OK"
}

我们可以看到格式化的地址不正确,国家名称是 TZ 而不是坦桑尼亚等。我想将此数据传递给地理编码,以便我可以拥有视口和其他几何数据,但为此我需要一个适当的地址,如 predictions.description 中给出的地址。有没有办法在自动完成中选择这个地方时获取这些数据?还是有其他方法可以获取对这个地方进行地理编码所需的信息?

非常感谢

4

0 回答 0