Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Map API geocoder language not working

I make 2 requests to Google Map API geocoder in different languages:

geocoder.geocode({
    'latLng': latlng,
    'language': 'en'
}, function(results, status) {
    if (status == google.maps.GeocoderStatus.OK) {
        $address_en.val(results[0].formatted_address);
    }
});

geocoder.geocode({
    'latLng': latlng,
    'language': 'ja'
}, function(results, status) {
    if (status == google.maps.GeocoderStatus.OK) {
        $address_ja.val(results[0].formatted_address);
    }
});

But geocoder use default language in both request.

--- Update: ---

I don’t see language parameter in new API documentation (Reference). But it existed earlier.

I found it in Changelog:

3.5 June 8, 2011

Noticeable changes:

  • Removed GeocoderRequest’s "language" option

Is it possible to do this now?

like image 767
Modder Avatar asked Apr 08 '26 10:04

Modder


1 Answers

The google.maps.GeocoderRequest object does not have a language property.

The addresses will be returned by the Geocoder using the browser's preferred language setting, or the language specified when loading the API JavaScript using the language parameter. (For more information, see Localization.)

Source: https://developers.google.com/maps/documentation/javascript/geocoding

like image 80
MrUpsidown Avatar answered Apr 11 '26 00:04

MrUpsidown