wrap pushing to track store into a try/catch, make coords a plain object
authorRobert Kaiser <kairo@kairo.at>
Sun, 26 Feb 2012 01:04:30 +0000 (02:04 +0100)
committerRobert Kaiser <kairo@kairo.at>
Sun, 26 Feb 2012 01:04:30 +0000 (02:04 +0100)
js/map.js

index d59d06020c758d13c321fc7496dbdf676672d714..4185e0cba0a7abfedfd2ffbeb870a776b596de42 100644 (file)
--- a/js/map.js
+++ b/js/map.js
@@ -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,