Theofilos Mouratidis
Theofilos Mouratidis

Reputation: 1156

google geocoder change results by language

I have this code which tries to get the demo data from Hindi language for example, I run it from a local .html I created in desktop.

var xmlhttp;

if (window.XMLHttpRequest)
{
    xmlhttp = new XMLHttpRequest();
}
else
{
    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}

xmlhttp.open("GET", "http://maps.googleapis.com/maps/api/geocode/xml?latlng=40.714224,-73.961452&language=hi&sensor=true", true);

xmlhttp.onreadystatechange = function ()
{
    if (xmlhttp.readyState != 4) return;
    if (xmlhttp.status != 200 && xmlhttp.status != 304) return;
    document.write(xmlhttp.responseText);
};

xmlhttp.send(null);

Google doesn't allow me to get the data because of Access-Control-Allow-Origin. What should I do to get these data, I am really confused...

Upvotes: 1

Views: 1562

Answers (1)

Mano Marks
Mano Marks

Reputation: 8819

Instead of using a direct web call, you should be using the JavaScript Google Maps API with the built-in geocoding service. And you can set the language as a parameter to the JavaScript loader: maps.googleapis.com/maps/api/js?sensor=false&language=hi

Upvotes: 1

Related Questions