简体   繁体   English

Google Maps API未返回英文国家/地区名称

[英]Google Maps API not returning English country name

I use the below API link to retrieve JSON based on longitude and latitude; 我使用以下API链接来检索基于经度和纬度的JSON; however, I notice that for different users it doesn't always return the JSON in English format. 但是,我注意到对于不同的用户,它并不总是以英文格式返回JSON。 I have already added the "language=en" 我已经添加了“language = en”

https://maps.googleapis.com/maps/api/geocode/json?latlng=" + latitude + "," + longitude + "&key=xxx&language=en"

There is no reason why your request would not return the results you can expect from what is explained in the documentation . 您的请求没有理由不返回您可以文档中解释的结果返回的结果

  • The geocoder does its best to provide a street address that is readable for both the user and locals. 地理编码器尽力提供可供用户和当地人阅读的街道地址 To achieve that goal, it returns street addresses in the local language, transliterated to a script readable by the user if necessary, observing the preferred language. 为了实现该目标,它以本地语言返回街道地址,必要时音译为用户可读的脚本,并观察首选语言。 All other addresses are returned in the preferred language. 所有其他地址都以首选语言返回。 Address components are all returned in the same language, which is chosen from the first component . 地址组件都以相同的语言返回,该语言是从第一个组件中选择的

  • If a name is not available in the preferred language, the geocoder uses the closest match . 如果名称不是首选语言,则地理编码器使用最接近的匹配

  • The preferred language has a small influence on the set of results that the API chooses to return , and the order in which they are returned. 首选语言对API选择返回的结果集以及返回的顺序影响很小 The geocoder interprets abbreviations differently depending on language, such as the abbreviations for street types, or synonyms that may be valid in one language but not in another. 地理编码器根据语言不同地解释缩写,例如街道类型的缩写,或者可能在一种语言中有效而在另一种语言中无效的同义词。 For example, utca and tér are synonyms for street in Hungarian. 例如,utca和tér是匈牙利语中的街道的同义词。

The list of supported languages is here: https://developers.google.com/maps/faq?hl=en#languagesupport 支持的语言列表位于: https//developers.google.com/maps/faq?hl = zh_CN #languagesupport

replace "language=en" with "language=en_AU" set language code with specific country code 将“language = en”替换为“language = en_AU”,将语言代码替换为特定的国家/地区代码

check here for language code: https://developers.google.com/maps/faq#languagesupport 点击此处查看语言代码: https//developers.google.com/maps/faq#languagesupport

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM