地方详情API的short_name更改 [英] Changes in short_name for Place Details API

查看:75
本文介绍了地方详情API的short_name更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Google响应的格式是否更改? 几天以来,当我使用与某个国家/地区相对应的place_id参数查询API时,再也没有任何国家/地区代码(alpha2).

例如:

# Query for "France"
# http://maps.googleapis.com/maps/api/js/GeocodeService.Search?7sUS&9sen&14sChIJMVd4MymgVA0R99lHx5Y__Ws&key=[API_KEY]

"results" : [
  {
     "address_components" : [
        {
           "long_name" : "France",
           "short_name" : "France", <= Used to be "FR"
           "types" : [ "country", "political" ]
        }
     ],
     "formatted_address" : "France",
       ....
     },
     "place_id" : "ChIJMVd4MymgVA0R99lHx5Y__Ws",
     "types" : [ "country", "political" ]
  }
  ],
  "status" : "OK"
  }

但是当我对法国巴黎执行相同的查询时:

"results" : [
  {
     "address_components" : [
        {
           "long_name" : "Paris",
           "short_name" : "Paris",
           "types" : [ "locality", "political" ]
        },
        {
           "long_name" : "Paris",
           "short_name" : "Paris",
           "types" : [ "administrative_area_level_2", "political" ]
        },
        {
           "long_name" : "Île-de-France",
           "short_name" : "Île-de-France",
           "types" : [ "administrative_area_level_1", "political" ]
        },
        {
           "long_name" : "France",
           "short_name" : "FR",  <== Still "FR"
           "types" : [ "country", "political" ]
        }
     ],
     "formatted_address" : "Paris, France",
     "geometry" : {
        "bounds" : {
           "northeast" : {
              "lat" : 48.9021449,
              "lng" : 2.4699208
           },
           "southwest" : {
              "lat" : 48.815573,
              "lng" : 2.224199
           }
        },
        "location" : {
           "lat" : 48.856614,
           "lng" : 2.3522219
        },
        "location_type" : "APPROXIMATE",
        "viewport" : {
           "northeast" : {
              "lat" : 48.9021449,
              "lng" : 2.4699208
           },
           "southwest" : {
              "lat" : 48.815573,
              "lng" : 2.225193
           }
        }
     },
     "place_id" : "ChIJD7fiBh9u5kcRYJSMaMOCCwQ",
     "types" : [ "locality", "political" ]
  }
  ],
  "status" : "OK"
  }
  )

真的改变了吗?如果是这样,如何获取有关某个国家的查询的相应country_code?

感谢您的帮助

解决方案

这似乎是一个错误.请在公共问题跟踪器中查看该报告:

https://issuetracker.google.com/issues/37479392

随时添加您的评论并为问题加注星标.

更新

此问题已由Google在2017年4月27日解决.

Did the format of the Google response change ? Since a few days, when I query the API with a place_id parameter corresponding to a country, I don't get any country code (alpha2) anymore.

For example:

# Query for "France"
# http://maps.googleapis.com/maps/api/js/GeocodeService.Search?7sUS&9sen&14sChIJMVd4MymgVA0R99lHx5Y__Ws&key=[API_KEY]

"results" : [
  {
     "address_components" : [
        {
           "long_name" : "France",
           "short_name" : "France", <= Used to be "FR"
           "types" : [ "country", "political" ]
        }
     ],
     "formatted_address" : "France",
       ....
     },
     "place_id" : "ChIJMVd4MymgVA0R99lHx5Y__Ws",
     "types" : [ "country", "political" ]
  }
  ],
  "status" : "OK"
  }

But when I perform the same query for Paris, France:

"results" : [
  {
     "address_components" : [
        {
           "long_name" : "Paris",
           "short_name" : "Paris",
           "types" : [ "locality", "political" ]
        },
        {
           "long_name" : "Paris",
           "short_name" : "Paris",
           "types" : [ "administrative_area_level_2", "political" ]
        },
        {
           "long_name" : "Île-de-France",
           "short_name" : "Île-de-France",
           "types" : [ "administrative_area_level_1", "political" ]
        },
        {
           "long_name" : "France",
           "short_name" : "FR",  <== Still "FR"
           "types" : [ "country", "political" ]
        }
     ],
     "formatted_address" : "Paris, France",
     "geometry" : {
        "bounds" : {
           "northeast" : {
              "lat" : 48.9021449,
              "lng" : 2.4699208
           },
           "southwest" : {
              "lat" : 48.815573,
              "lng" : 2.224199
           }
        },
        "location" : {
           "lat" : 48.856614,
           "lng" : 2.3522219
        },
        "location_type" : "APPROXIMATE",
        "viewport" : {
           "northeast" : {
              "lat" : 48.9021449,
              "lng" : 2.4699208
           },
           "southwest" : {
              "lat" : 48.815573,
              "lng" : 2.225193
           }
        }
     },
     "place_id" : "ChIJD7fiBh9u5kcRYJSMaMOCCwQ",
     "types" : [ "locality", "political" ]
  }
  ],
  "status" : "OK"
  }
  )

Dit it really change ? If so, how can I get the corresponding country_code for a query about a country ?

Thanks for your help

解决方案

It seems to be a bug. Please have a look at the report in the public issue tracker:

https://issuetracker.google.com/issues/37479392

Feel free to add your comments and star the issue.

UPDATE

The issue was resolved by Google on April 27, 2017.

这篇关于地方详情API的short_name更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆