try to deal with the default scaling of mobile devices, eliminate white borders aroun...
[lantea.git] / js / map.js
index 385b36f84bb9f7d7f5ef6f72c2c0784d715f656a..69993243a3a6568a673bb7412fef3b92b9313db0 100644 (file)
--- a/js/map.js
+++ b/js/map.js
@@ -3,7 +3,7 @@
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 var gCanvas, gContext, gGeolocation;
-var gDebug = true;
+var gDebug = false;
 
 var gTileSize = 256;
 var gMaxZoom = 18; // The minimum is 0.
@@ -131,11 +131,11 @@ function initMap() {
 }
 
 function resizeAndDraw() {
-  var viewportWidth = window.innerWidth;
-  var viewportHeight = window.innerHeight;
+  var viewportWidth = Math.min(window.innerWidth, window.outerWidth);
+  var viewportHeight = Math.min(window.innerHeight, window.outerHeight);
 
-  var canvasWidth = viewportWidth * 0.98;
-  var canvasHeight = (viewportHeight - 100) * 0.98;
+  var canvasWidth = viewportWidth - 2;
+  var canvasHeight = viewportHeight - 2;
   gCanvas.style.position = "fixed";
   gCanvas.width = canvasWidth;
   gCanvas.height = canvasHeight;
@@ -475,15 +475,21 @@ function startTracking() {
       return;
   };
   getStoredTrack();
-  if (navigator.geolocation) {
+  if (gGeolocation) {
     gGeoWatchID = gGeolocation.watchPosition(
       function(position) {
         // Coords spec: https://developer.mozilla.org/en/XPCOM_Interface_Reference/NsIDOMGeoPositionCoords
         var tPoint = {time: position.timestamp,
-                      coords: position.coords,
+                      coords: {latitude: position.coords.latitude,
+                               longitude: position.coords.longitude,
+                               altitude: position.coords.altitude,
+                               accuracy: position.coords.accuracy,
+                               altitudeAccuracy: position.coords.altitudeAccuracy,
+                               heading: position.coords.heading,
+                               speed: position.coords.speed},
                       beginSegment: !gLastTrackPoint};
         gTrack.push(tPoint);
-        gTrackStore.push(tPoint);
+        try { gTrackStore.push(tPoint); } catch(e) {}
         drawTrackPoint(position.coords.latitude, position.coords.longitude);
         if (gCenterPosition) {
           var posCoord = gps2xy(position.coords.latitude,