create hackish way to save GPX tracks and make the map only shift when we get enough...
[lantea.git] / js / map.js
index 1ce622642e52fe54dd09aeacdd42695381f0cb95..4cd4ea7b809ea786d1ca1dbdbd1ee8be86ab6e24 100644 (file)
--- a/js/map.js
+++ b/js/map.js
@@ -418,9 +418,12 @@ function startTracking() {
         drawTrackPoint(position.coords.latitude, position.coords.longitude);
         if (gCenterPosition) {
           var posCoord = gps2xy(position.coords.latitude, position.coords.longitude);
         drawTrackPoint(position.coords.latitude, position.coords.longitude);
         if (gCenterPosition) {
           var posCoord = gps2xy(position.coords.latitude, position.coords.longitude);
-          gPos.x = posCoord.x;
-          gPos.y = posCoord.y;
-          drawMap();
+          if (Math.abs(gPos.x - posCoord.x) > gCanvas.width * gZoomFactor / 4 ||
+              Math.abs(gPos.y - posCoord.y) > gCanvas.height * gZoomFactor / 4) {
+            gPos.x = posCoord.x;
+            gPos.y = posCoord.y;
+            drawMap();
+          }
         }
       },
       function(error) {
         }
       },
       function(error) {