From 5384f91a657c38561fde7a9d57814c6c65845fbf Mon Sep 17 00:00:00 2001 From: Tor-Einar Skog <tor-einar.skog@nibio.no> Date: Fri, 15 Sep 2017 15:34:05 +0200 Subject: [PATCH] Making sure geolocation works - forcing user to https --- .../webapp/map_applications/fireblight/js/map.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/webapp/map_applications/fireblight/js/map.js b/src/main/webapp/map_applications/fireblight/js/map.js index 8aff3b4e..b1aa6337 100755 --- a/src/main/webapp/map_applications/fireblight/js/map.js +++ b/src/main/webapp/map_applications/fireblight/js/map.js @@ -537,13 +537,23 @@ var navigateTo = function(center) function navToLocation() { if (navigator.geolocation) { + if(window.location.protocol === "https") + { navigator.geolocation.getCurrentPosition(function(geopositionObj){ navigateTo([geopositionObj.coords.longitude, geopositionObj.coords.latitude]); } ); - } else { - alert( "Geolocation is not supported by this browser."); } + else + { + if(confirm("Lokalisering fungerer bare over https (sikker tilkobling mellom nettleser og tjener). Klikk OK for å gå til sikker tilkobling.")) + { + window.location = "https:" + window.location.href.substring(window.location.protocol.length); + } + } + } else { + alert( "Lokaliseringsfunksjonen er ikke tilgjengelig i denne nettleseren."); + } } -- GitLab