I'm trying to set up client location detection for my mobile web site using the code below:
<html>
<head>
</head>
<body>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false&libraries=geometry"></script>
<script>
var geocoder = new google.maps.Geocoder();
var loc = {};
if(google.loader.ClientLocation) {
loc.lat = google.loader.ClientLocation.latitude;
loc.lng = google.loader.ClientLocation.longitude;
}
var clientLocation = new google.maps.LatLng(loc.lat, loc.lng);
alert(clientLocation);
</script>
</body>
</html>
This works fine on Safari on my desktop by returns (NaN,NaN) when I run it on the Safari mobile browser. Can anyone suggest what might be going wrong?