Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

As the API reference states:

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 doesn't seem to have effect (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) {}
);
like image 968
0xbadf00d Avatar asked Nov 30 '11 15:11

0xbadf00d


1 Answers

The API link you are refering to is not that same as what you are using in your code example.

I beleive what you are looking for is this API, which makes me wonder how the above returns any restuls, since it is expecting a bounds and not latLng, and also it does not support the language key.

However in order to get the results in another language you can change the way you include your google maps script according to this section of the docs like so

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

On the other hand if you are really working with the Geocoding API (Web service), then your url requests need to look something like this (changing the json to xml if you want xml out, and changing en to whatever language you want)

http://maps.googleapis.com/maps/api/geocode/json?latlng=YOUR-LAT-LNG&language=en
like image 176
omarello Avatar answered Oct 11 '22 03:10

omarello