google.maps.places.Autocomplete language output

淺唱寂寞╮ 提交于 2019-12-21 07:53:23

问题


I am using google.maps.places.Autocomplete object and always get results in Ukrainian language.

I am loading library like that

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


回答1:


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."

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 list of languages

Edit:

Try setting this on language parameter

language=ru-RU



回答2:


Have you tried language=ru instead 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 ru works.

Have a look also at table of languages: https://developers.google.com/maps/faq#languagesupport

There is no ru-RU, only ru.



来源:https://stackoverflow.com/questions/28130114/google-maps-places-autocomplete-language-output

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!