Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changes in short_name for Place Details API

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

like image 542
GrégoireC Avatar asked Apr 24 '17 19:04

GrégoireC


People also ask

How do you refresh a place id?

You can refresh Place IDs at no charge, by making a Place Details request, specifying only the place_id field in the fields parameter. This will trigger the Places Details - ID Refresh SKU.

What is the best way to display information about a certain location in Google Maps API?

Once you have a place_id from a Place Search, you can request more details about a particular establishment or point of interest by initiating a Place Details request.

Can you store Google Places API data?

Note that the place ID, used to uniquely identify a place, is exempt from the caching restriction. You can therefore store place ID values indefinitely.


1 Answers

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.

like image 139
xomena Avatar answered Oct 22 '22 11:10

xomena