From 4b03e1f7b7cd779050bcea2e3b4215d6835c4654 Mon Sep 17 00:00:00 2001 From: Burathar Date: Wed, 22 Jul 2020 18:42:37 +0200 Subject: [PATCH] console log geolocation errors --- app/templates/player_base.html | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/app/templates/player_base.html b/app/templates/player_base.html index 866e40e..29bb2e2 100644 --- a/app/templates/player_base.html +++ b/app/templates/player_base.html @@ -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.')