Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
211 views
in Technique[技术] by (71.8m points)

java - How can I get Chinese words using Google API with JSON?

I'm using the following link.

But, the result is not Chinese.

My server is Amazon Web Services (AWS).

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

From https://developers.google.com/maps/documentation/geocoding/intro#geocoding

The geocoder will do its best to provide a street address that is readable for both the user and locals. To achieve that goal, it will return street addresses in the local language, transliterated to a script readable by the user if necessary, observing the preferred language. All other addresses will be returned in the preferred language. Address components will all be returned in the same language, which is chosen from the first component. Should names not be available in the preferred language, the closest match will be used

This is probably easier to grasp through examples. The result in your example is an address in the USA, where the local language (at least officially the major one 0:) is English, and that's the language in which the address is useful in practice.

Consider this: what can you do with a US address all in Chinese?

  • It would not be useful for a Chinese speaker tourist, because it cannot be compared with local street signs.

  • It would not be useful for a local (assuming English speaker, not Chinese speaker) because it is not even readable.

The English address is readable for both, and that applies to both the choice of language and script. This is also consistent with Google Maps: just click once on any point on a street, you'll see the address is in English, despite the language preference override to zh-CN:

https://www.google.com/maps/@40.714224,-73.961452,18z?hl=zh-CN

Maybe it's better illustrated with this example:

https://maps.googleapis.com/maps/api/geocode/json?&latlng=22.277978,114.174213&language=zh-CN

formatted_address: 香港灣仔軒尼詩道183-185號兆安大樓

https://maps.googleapis.com/maps/api/geocode/json?&latlng=22.277978,114.174213&language=de

formatted_address: Siu On Mansion, 183-185 Hennessy Rd, Wan Chai, Hongkong

Address in English is (more likely) usable by both locals and a German tourist (country name is always in your chosen language).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...