Change the language in which Geocoder.geocode () returns the results

As indicated in the API :

The Geocoding API defines a geocoding request using the following URL parameters: - language (optional) — The language in which to return results. See the supported list of domain languages. Note that we often update supported languages so this list may not be exhaustive. If language is not supplied, the geocoder will attempt to use the native language of the domain from which the request is sent wherever possible. 

However, specifying the language parameter seems inefficient (tested with Firefox 8, IE 9, and Chrome 15).

 new google.maps.Geocoder().geocode({ 'latLng' : new google.maps.LatLng(position.coords.latitude, position.coords.longitude), 'language': 'en'}, function(results, status) {} ); 
+6
source share
1 answer

The reference to the API you are referring to is not the same as what you use in your code example.

I believe that you are looking for this API , which makes me wonder how the above returns any restuls, since it expects bounds , not latLng , and also does not support the language key.

However, in order to get the results in another language, you can change the way your google script maps are included in accordance with this section of the documents , thus

 <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false&language=ja"></script> 

On the other hand, if you really work with the Geocoding API (web service) , then your URL requests should look something like this (change json to xml, if you want xml to go out and change en to whatever language you want)

 http://maps.googleapis.com/maps/api/geocode/json?latlng=YOUR-LAT-LNG&language=en 
+15
source

Source: https://habr.com/ru/post/902759/


All Articles