Is google.loader.clientlocation still supported
Asked Answered
J

1

18

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>
Jurisprudence answered 7/1, 2013 at 12:21 Comment(6)
it's still working, but not reliableKuehnel
Thanks for answer, do you have some link that says that. From the second link I mention in question it seems even Google tell to use something else.Jurisprudence
I don't have a link, but I know it because yesterday it returns a result for me(no good one, 300km away from my position). There may be no active support, but it's still present(otherwise I wouldn't get a result yesterday and google.loader.ClientLocation would be undefined when no result is available, but it's null). I haven't seen any official announcement that it's not supported anymore, a comment inside a newsgroup is not an official statement.Kuehnel
But the second link is from a google engeneer at google-ajax-apis. My question is more about it being still supported or close to be abandoned by google.Jurisprudence
the 2nd link did not contain any detail about the future-plans. you may ask themKuehnel
I can't find any documentation regarding whether it's officially supported or deprecated, but in the current source https://www.google.com/jsapi, it reads google.loader.ClientLocation = null;. But while ClientLocation is initialized to null, it is neither called nor otherwise assigned to anywhere else in the code, so the call to google.loader.ClientLocation will presumably return null whenever invoked.Coyote
J
16

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

Jurisprudence answered 9/1, 2013 at 17:59 Comment(1)
then what did you use to fetch user current location ?Kajdan

© 2022 - 2024 — McMap. All rights reserved.