if(navigator.geolocation){
navigator.geolocation.getCurrentPosition(success_handler, errors_handler);
function success_handler(position){
console.log('Latitude: ' + position.coords.latitude + '\n Longitude: ' + position.coords.longitude);
}
function error_handler(err) {
switch(err.code){
case err.PERMISSION_DENIED:
console.log('User refused to share geolocation data');
break;
case err.POSITION_UNAVAILABLE:
console.log('Current position is unavailabel');
break;
case err.TIMEOUT:
console.log('Timed out');
break;
default:
console.log('Unknown error');
break;
}
}
}
}
getCurrentPosition: position.coords.latitude, position.coords.longitude, position.coords.altitude, position.coords.accuracy;
watchCurrentPosition: position.coords.heading, position.coords.speed;