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:
- https://groups.google.com/forum/?fromgroups=#!topic/google-ajax-search-api/8q_oG-Y9fp8
- http://code.google.com/p/google-ajax-apis/issues/detail?id=586
- https://groups.google.com/forum/?fromgroups=#!topic/google-ajax-search-api/rzoIh4RrtOQ
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>
google.loader.ClientLocation
would beundefined
when no result is available, but it'snull
). I haven't seen any official announcement that it's not supported anymore, a comment inside a newsgroup is not an official statement. – Kuehnelhttps://www.google.com/jsapi
, it readsgoogle.loader.ClientLocation = null;
. But whileClientLocation
is initialized tonull
, it is neither called nor otherwise assigned to anywhere else in the code, so the call togoogle.loader.ClientLocation
will presumably return null whenever invoked. – Coyote