From d361104be0372268e187b7576042127090375566 Mon Sep 17 00:00:00 2001 From: Robert Kaiser Date: Mon, 7 Mar 2016 02:23:57 +0100 Subject: [PATCH] support and set GPS wakelock for Firefox OS --- js/map.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/js/map.js b/js/map.js index c7a69e8..f02386b 100644 --- a/js/map.js +++ b/js/map.js @@ -75,7 +75,7 @@ var gMapPrefsLoaded = false; var gDragging = false; var gDragTouchID, gPinchStartWidth; -var gGeoWatchID; +var gGeoWatchID, gGPSWakeLock; var gTrack = []; var gLastTrackPoint, gLastDrawnPoint; var gCenterPosition = true; @@ -1119,6 +1119,9 @@ function startTracking() { if (gGeolocation) { gActionLabel.textContent = "Establishing Position"; gAction.style.display = "block"; + if (navigator.requestWakeLock) { + gGPSWakeLock = navigator.requestWakeLock("gps"); + } gGeoWatchID = gGeolocation.watchPosition( function(position) { if (gActionLabel.textContent) { @@ -1174,6 +1177,10 @@ function endTracking() { gActionLabel.textContent = ""; gAction.style.display = "none"; } + if (navigator.requestWakeLock && gGPSWakeLock) { + console.log("releasing WakeLock"); + gGPSWakeLock.unlock(); + } if (gGeoWatchID) { gGeolocation.clearWatch(gGeoWatchID); } -- 2.35.3