Changes in short_name for Place Details API

2019-02-17 18:20发布

问题:

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

回答1:

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.