0
votes

Why do I get reponse with a different place_id, then the one I used in my place details API query?

https://maps.googleapis.com/maps/api/place/details/json?placeid=Eiw5LzUwIE1hcmtldCBTdHJlZXQsIE1lbGJvdXJuZSBWSUMsIEF1c3RyYWxpYSIwEi4KFAoSCR3TztZMXdZqEREXsZzx5CRAEDIqFAoSCXUvVtBMXdZqEc9Cc6QFzzMr&fields=address_components,formatted_address,place_id,types&key=

{
   "html_attributions" : [],
   "result" : {
      "address_components" : [
         {
            "long_name" : "50",
            "short_name" : "50",
            "types" : [ "street_number" ]
         },
         {
            "long_name" : "Market Street",
            "short_name" : "Market St",
            "types" : [ "route" ]
         },
         {
            "long_name" : "Melbourne",
            "short_name" : "Melbourne",
            "types" : [ "locality", "political" ]
         },
         {
            "long_name" : "Melbourne City",
            "short_name" : "Melbourne",
            "types" : [ "administrative_area_level_2", "political" ]
         },
         {
            "long_name" : "Victoria",
            "short_name" : "VIC",
            "types" : [ "administrative_area_level_1", "political" ]
         },
         {
            "long_name" : "Australia",
            "short_name" : "AU",
            "types" : [ "country", "political" ]
         },
         {
            "long_name" : "3000",
            "short_name" : "3000",
            "types" : [ "postal_code" ]
         }
      ],
      "formatted_address" : "50 Market St, Melbourne VIC 3000, Australia",
      "place_id" : "Eis1MCBNYXJrZXQgU3QsIE1lbGJvdXJuZSBWSUMgMzAwMCwgQXVzdHJhbGlhIjASLgoUChIJHdPO1kxd1moRERexnPHkJEAQMioUChIJdS9W0Exd1moRz0JzpAXPMys",
      "types" : [ "street_address" ]
   },
   "status" : "OK"
}

Also I noticed the address returned is different.

The placeid in my query, is what I received for an autocompletion service response.

{
     "description" : "9/50 Market Street, Melbourne VIC, Australia",
     "id" : "06f000a321dc5f1347b79dcbe4d611390f750f36",
     "matched_substrings" : [
        {
           "length" : 18,
           "offset" : 0
        }
     ],
     "place_id" : "Eiw5LzUwIE1hcmtldCBTdHJlZXQsIE1lbGJvdXJuZSBWSUMsIEF1c3RyYWxpYSIwEi4KFAoSCR3TztZMXdZqEREXsZzx5CRAEDIqFAoSCXUvVtBMXdZqEc9Cc6QFzzMr",
     "reference" : "Eiw5LzUwIE1hcmtldCBTdHJlZXQsIE1lbGJvdXJuZSBWSUMsIEF1c3RyYWxpYSIwEi4KFAoSCR3TztZMXdZqEREXsZzx5CRAEDIqFAoSCXUvVtBMXdZqEc9Cc6QFzzMr",
     "structured_formatting" : {
        "main_text" : "9/50 Market Street",
        "main_text_matched_substrings" : [
           {
              "length" : 18,
              "offset" : 0
           }
        ],
        "secondary_text" : "Melbourne VIC, Australia"
     },
     "terms" : [
        {
           "offset" : 0,
           "value" : "9/50 Market Street"
        },
        {
           "offset" : 20,
           "value" : "Melbourne"
        },
        {
           "offset" : 30,
           "value" : "VIC"
        },
        {
           "offset" : 35,
           "value" : "Australia"
        }
     ],
     "types" : [ "route", "geocode" ]
  }

Looks like for some reason, google maps is dropping the subpermise information, when using the place details API and returning the street_address.

Is there a way I can force google maps API to return me the details for the subpremise?

1

1 Answers

1
votes

The long place ID like Eis1MCBNYXJrZXQgU3QsIE1lbGJvdXJuZSBWSUMgMzAwMCwgQXVzdHJhbGlhIjASLgoUChIJHdPO1kxd1moRERexnPHkJEAQMioUChIJdS9W0Exd1moRz0JzpAXPMys in your example means that there is no exact street address for your search in database of Google. This is an approximation. When you search an address that exists in the database you will get shorter place ID (e.g. ChIJrTLr-GyuEmsRBfy61i59si0).

If address doesn't exists in Google database you can get one long place ID from autocomplete service and a different long place ID from the place details endpoint. These endpoints can use different algorithms for approximations that results in different place IDs for addresses that are not found in the database.

Both types of place IDs are mentioned in the documentation https://developers.google.com/places/place-id#id-overview

The most straightforward way to fix the issue is reporting a missing address to Google data team as described in https://support.google.com/maps/answer/6320846.

Once added in Google database your issue will disappear, you will get a short place ID both in autocomplete and in details.

Also your issue might be related to the bug reported in Google issue tracker regarding limited support of subpremises in place autocomplete service. Have a look at

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

I hope this addresses your doubt.