Burathar
4 years ago
7 changed files with 57 additions and 39 deletions
@ -0,0 +1,26 @@ |
|||||||
|
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; |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue