In my app I'm using google.maps.places.Autocomplete.getPlace()
in order to get info such the name of a city, the problem is that the informations retrieved are localized according to the "language
" parameter passed via querystring when importing the library, instead I would like to have them always in english, while preserving localization in the autocomplete and the rendered map (that is, if the user is italian he will see for example "Venezia" in the UI, but in my client-side api I will get "Venice")... how can I do?
Autocomplete predictions reflect real searches that have been done on Google. To determine what predictions to show, our systems look for common queries that match what someone starts to enter into the search box but also consider: The language of the query. The location a query is coming from.
The autocomplete widget is a search dialog with built-in autocomplete functionality. As a user enters search terms, the widget presents a list of predicted places to choose from. When the user makes a selection, a Place instance is returned, which your app can then use to get details about the selected place.
Okay, I found it here: https://developers.google.com/maps/documentation/javascript/basics#Localization
So basically you need to provide language
parameter when loading Google API:
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?language=en">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With