Is google.loader.clientlocation still supported

user1565007 picture user1565007 · Jan 7, 2013 · Viewed 28.4k times · Source

I have made some tests using google.loader.ClientLocation from:

But I get null for the test:

if (google.loader.ClientLocation) 

This is the behaviour when google does not find information for IP.

I searched StackOverflow and there are a lot of questions regarding it but no good answers.

I searched the net and saw these 2 links:

Which seem to say the navigator HTML geo location should be used.

Google API documentation does not mention it anymore.

I would like a confirmation of wether Google google.loader.clientlocation is still working or not ?

My code is the following:

<html>
<head>
  <script type="text/javascript" src="http://www.google.com/jsapi"></script>
</head>
<body>
<script type="text/javascript"> 
function geoTest() {

    if (google.loader.ClientLocation) {

        var latitude = google.loader.ClientLocation.latitude;
        var longitude = google.loader.ClientLocation.longitude;
        var city = google.loader.ClientLocation.address.city;
        var country = google.loader.ClientLocation.address.country;
        var country_code = google.loader.ClientLocation.address.country_code;
        var region = google.loader.ClientLocation.address.region;

        var text = 'Your Location<br /><br />Latitude: ' + latitude + '<br />Longitude: ' + longitude + '<br />City: ' + city + '<br />Country: ' + country + '<br />Country Code: ' + country_code + '<br />Region: ' + region;

    } else {

        var text = 'Google was not able to detect your location';

    }

    document.write(text);
}

geoTest();

</script>
</body>
</html>

Answer

user1565007 picture user1565007 · Jan 9, 2013

It seems this API is kind of "deprecated" although it still works for some IPs.

This is the answer I got from here:

The geolocation functionality in the Loader hasn't been retired, per se. We stopped documenting it several years ago and have recommended the HTML-based solutions due to their improved accuracy, but the functionality itself has not been removed from the Loader at this time. Thanks!

So when location is not found for IP, google.loader.ClientLocation is null