prepare for OAuth support but don't enable it as actually GPS trace creation doesn...
[lantea.git] / js / map.js
index dcb40a3a17bc9f8c55c9e00ac2c1c4983bc12b00..d1f6b03c93cc7e4164f4cc671c7702fa9617d415 100644 (file)
--- a/js/map.js
+++ b/js/map.js
@@ -88,7 +88,7 @@ var gMapPrefsLoaded = false;
 var gDragging = false;
 var gDragTouchID, gPinchStartWidth;
 
-var gGeoWatchID;
+var gGeoWatchID, gGPSWakeLock;
 var gTrack = [];
 var gLastTrackPoint, gLastDrawnPoint;
 var gCenterPosition = true;
@@ -1132,6 +1132,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) {
@@ -1187,6 +1190,10 @@ function endTracking() {
     gActionLabel.textContent = "";
     gAction.style.display = "none";
   }
+  if (navigator.requestWakeLock && gGPSWakeLock) {
+    console.log("releasing WakeLock");
+    gGPSWakeLock.unlock();
+  }
   if (gGeoWatchID) {
     gGeolocation.clearWatch(gGeoWatchID);
   }