简体   繁体   English

Google Maps自动完成功能中的城市不是英语

[英]Cities from Google Maps autocomplete are not in English

  1. I use the parameter language=en when I'm connecting Google Maps API. 连接Google Maps API时,我使用参数language = en

  2. I use this code for detecting the city : 我使用此代码来检测城市

     function locationHelper(array, key) { var location = false; $.each(array, function (i, object) { if (object.types[0] == key) { location = (object.long_name != "") ? object.long_name : object.short_name; } }); return location; } autocomplete.addListener('place_changed', function() { var place = autocomplete.getPlace(); var city = locationHelper(place.address_components, 'locality'); console.log(city); }); 

在此处输入图片说明

Why Google sends me Bucharest in Romanian variant (București) when I'm displaying data from autocomplete.getPlace()? 当我显示来自autocomplete.getPlace()的数据时,为什么Google会用罗马尼亚语变体(București)向我发送布加勒斯特?


From documentation: 从文档:

The default placeholder text is localized automatically. 默认占位符文本已自动本地化。 If you specify your own placeholder value, you must handle the localization of that value in your application. 如果指定自己的占位符值,则必须在应用程序中处理该值的本地化。 For information on how the Google Maps JavaScript API chooses the language to use, please read the documentation on localization. 有关Google Maps JavaScript API如何选择使用语言的信息,请阅读有关本地化的文档。


I did it at the very beginning. 我在一开始就做到了。 As we can see, Google proposes us to select a language for variants. 如我们所见,Google建议我们为变体选择一种语言。 Only for variants, there is no word on the results . 仅对于变体, 结果无字 And I didn't find any solution yet. 而且我还没有找到任何解决方案。

The address formatting for details follows a policy described by Google in the following document: 详细地址格式遵循Google在以下文档中描述的政策:

https://googlegeodevelopers.blogspot.com.es/2014/11/localization-of-street-addresses-in.html https://googlegeodevelopers.blogspot.com.es/2014/11/localization-of-street-addresses-in.html

Street-level addresses returned by the Google Maps Geocoding API now favor the local language, while keeping the address understandable as much as possible for both a user who only reads the requested language as well as locals. 现在,由Google Maps Geocoding API返回的街道级地址偏爱本地语言,而对于仅阅读所请求语言的用户和本地用户而言,该地址应尽可能地易于理解。 If the local language and user language both use the same alphabet, the Geocoding API will now return the local names for the streets and localities. 如果本地语言和用户语言都使用相同的字母,则Geocoding API现在将返回街道和位置的本地名称。

The same applies to Places API details, however, it looks like the autocomplete doesn't follow this guideline, but I believe Google currently is looking into this. 这同样适用于Places API详细信息,但是,自动填充似乎未遵循该准则,但我相信Google目前正在对此进行研究。

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

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