You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
883 B
26 lines
883 B
4 years ago
|
function getPosition(locationHandler){
|
||
|
if (navigator.geolocation) {
|
||
|
navigator.geolocation.getCurrentPosition(locationHandler, showError);
|
||
|
|
||
|
} else {
|
||
|
console.log('Geolocation is not supported by this browser.')
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function showError(error) {
|
||
|
switch(error.code) {
|
||
|
case error.PERMISSION_DENIED:
|
||
|
console.log("User denied the request for Geolocation.")
|
||
|
alert("Please refresh page and allow location sharing, otherwise the game won't work :'(")
|
||
|
break;
|
||
|
case error.POSITION_UNAVAILABLE:
|
||
|
console.log("Location information is unavailable.")
|
||
|
break;
|
||
|
case error.TIMEOUT:
|
||
|
console.log("The request to get user location timed out.")
|
||
|
break;
|
||
|
case error.UNKNOWN_ERROR:
|
||
|
console.log("An unknown error occurred.")
|
||
|
break;
|
||
|
}
|
||
|
}
|