Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

google.maps.places.Autocomplete language output

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

enter image description here

like image 886
yu.pitomets Avatar asked Jan 24 '15 20:01

yu.pitomets


People also ask

How do I restrict Google Maps autocomplete to certain cities?

It is currently not possible to restrict results to a specific locality. You can use bounds as you have done so above to bias results towards, but not restricted to places contained within the specified bounds. If you believe restriction by locality would be a useful feature please file a Places API - Feature Request.


Video Answer


2 Answers

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
like image 95
Ethaan Avatar answered Sep 18 '22 01:09

Ethaan


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.

like image 41
Danil Iakovlev Avatar answered Sep 18 '22 01:09

Danil Iakovlev