Javascript google.maps.places.Autocomplete 语言输出
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28130114/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
google.maps.places.Autocomplete language output
提问by yu.pitomets
I am using google.maps.places.Autocomplete object and always get results in Ukrainian language.
我正在使用 google.maps.places.Autocomplete 对象,并且总是以乌克兰语获得结果。
I am loading library like that
我正在加载这样的库
http://maps.google.com/maps/api/js?sensor=true&libraries=places&language=ru-RU
http://maps.google.com/maps/api/js?sensor=true&libraries=places&language=ru-RU
how to pass parameters to autocomplete language?
如何将参数传递给自动完成语言?
var autocomplete = new google.maps.places.Autocomplete($("#google_places_ac")[0], {});
google.maps.event.addListener(autocomplete, 'place_changed', function() {
var place = autocomplete.getPlace();
$scope.location = place.formatted_address;
// at that point $scope.location is in ukrainen, but I want Russian
$scope.$apply();
});
I've added image explains the problem. Text that squared with RED - is on Russian, text with Green - is on Ukraine. As you can see there is two different languages on the same map. Also input with Russian, and formatted language with Ukrainian. I believe this is a bug of Google map.s
我添加了图像来解释问题。与红色平方的文本 - 是俄语,文本与绿色 - 是乌克兰。如您所见,同一张地图上有两种不同的语言。还用俄语输入,用乌克兰语格式化语言。我相信这是 Google map.s 的一个错误


回答by Ethaan
According Docs
根据文档
"The API detects the browser settings of the user and set the language appropriately. It is possible to override the language in the APIs."
“API 检测用户的浏览器设置并适当设置语言。可以覆盖 API 中的语言。”
That means, that the input will change according user language on the browser
这意味着,输入将根据浏览器上的用户语言而改变
try on the script tag.
试试脚本标签。
<script src="http://maps.googleapis.com/maps/api/js?libraries=places&sensor=false&language=yourLanguage"></script>
take a look at this listof languages
看看这个语言列表
Edit:
编辑:
Try setting this on language parameter
尝试在语言参数上设置它
language=ru-RU
回答by Danil Iakovlev
Have you tried language=ruinstead of language=ru-RU? This works for me. For example, you can input address to Autocomplete in any supportable language, but autocomplete.getPlace() will return result in language from parameter and in case of Russian only ruworks.
您是否尝试过language=ru而不是language=ru-RU?这对我有用。例如,您可以使用任何可支持的语言向自动完成输入地址,但 autocomplete.getPlace() 将从参数返回语言结果,并且在仅俄语的情况下ru有效。
Have a look also at table of languages: https://developers.google.com/maps/faq#languagesupport
也看看语言表:https: //developers.google.com/maps/faq#languagesupport
There is no ru-RU, only ru.
没有ru-RU,只有ru。

