|
|
|
@ -32,9 +32,26 @@ function sendLocation(position) {
@@ -32,9 +32,26 @@ function sendLocation(position) {
|
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function showError(error) { |
|
|
|
|
switch(error.code) { |
|
|
|
|
case error.PERMISSION_DENIED: |
|
|
|
|
console.log("User denied the request for Geolocation.") |
|
|
|
|
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; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$(document).ready(function(){ |
|
|
|
|
if (navigator.geolocation) { |
|
|
|
|
navigator.geolocation.getCurrentPosition(sendLocation); |
|
|
|
|
navigator.geolocation.getCurrentPosition(sendLocation, showError); |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
console.log('Geolocation is not supported by this browser.') |
|
|
|
|