jquery script for location services
Would like to use the following java code on my main page "on load" event to detect if gps is turned on or not. I think that the script is good its just how to put it into the tiggzi javascript function window that im having issues with. I am thinking that its all about the function () tags. Any help would be great.
function initiate_geolocation() {
navigator.geolocation.getCurrentPosition(handle_geolocation_query,handle_errors);
}
function handle_errors(error)
{
switch(error.code)
{
case error.PERMISSION_DENIED: alert("GPS function not available right now");
break;
case error.POSITION_UNAVAILABLE: alert("Location services not turned on! Please enable location services prior to continuing.");
break;
case error.TIMEOUT: alert("retrieving position timed out");
break;
default: alert("unknown error");
break;
}
}
function handle_geolocation_query(position){
alert('Lat: ' + position.coords.latitude +
' Lon: ' + position.coords.longitude);
}