While using the getPlacePredictions
function on the AutocompleteService
, each result contains a description
field.
For example, when querying "times square", the first result has a description
of "Times Square, Manhattan, NY, USA".
After saving the place_id
of this result, and using it for the getDetails
function on the PlacesService
, the same place does not contain the description
field, but rather a field called formatted_address
which contains "Manhattan, NY 10036, USA".
How can i get the original description received using the AutocompleteService
when using the PlacesService
?
this is because each service has different response, the getPlacePredictions will return predictions which each have a description.the description field only tells you what the matched prediction is.
When you use getDetails you get formatted address which should be more accurate that the descriptions, You can also iterate the long_name field through address_components to build your desired address format.
For your query you can actually see that in the respond under the "name" field you can see "Times Square" and in the "formated_address":Manhattan, NY 10036, USA. which is the actual address for this PLACE details you requested.
So maybe you just need to consider this "name" field in the placeDetails response.
If you strictly need the value of "description" you can save this in a variable and use it as needed