I'm using Google Place Details API on my server to store information about a place, using the placeId
sent by a client.
I'm facing an issue regarding the language of the result, which differs when the place is a city or an address in that city, even when the language is specified in the query. For example:
The place id
ChIJ53USP0nBhkcRjQ50xhPN_zw
is the city of Milan, and the API returnsMilan
as locality andLombardy
as administrative area (English names)The place id
EjBWaWEgZGVsbGEgU3BpZ2EsIE1pbGFuLCBQcm92aW5jZSBvZiBNaWxhbiwgSXRhbHk
is a street in Milan, and the API returnsMilano
as locality andLombardia
as administrative area (Italian names)
To make it even weirder, both searches return Italy
as country. Is this the expected behavior of the API?
I think you can use some
Optional parameters
to set what language you want, such that:A Nearby Search request is an HTTP URL of the following form:
put
language
parameter, such that:For more detail, please refer here.
Is this the expected behavior of the API?
Yes, this is expected result. Even if you specify a language, it will return the response in that language only if there is one available, if not it will return the response in the language it was originally entered in.
Case 1:
Case 2:
Result when you search "Via della Spiga" in Google Map:
To learn more about this:
Translation of Places information into language specified by request. In this a request for a feature is asked that tells the developer in which language the results are so that they can take care of data accordingly, I personally think that would be great till the issue has not been fixed.
language parameter in place/details request not working
Both of the above issues are about 2 year old. Yet, Google is unable to resolve this issues.
One way to possibly solve this problem is by using textsearch:
As you can convert most of administrative area/city into any language name by using textsearch:
Example: Converting
"Lombardia"
into a chinese language:https://maps.googleapis.com/maps/api/place/textsearch/json?query=Lombardia&language=zh-CN&key=YOUR_API
Lombardia in chinese is 意大利伦巴第
When you search for placeID details, you get
address_components
array:So if you loop over the above array and use textsearch then you will get almost consistent address in a particular language.