add centering on track position
authorRobert Kaiser <kairo@kairo.at>
Sun, 18 Dec 2011 23:35:33 +0000 (00:35 +0100)
committerRobert Kaiser <kairo@kairo.at>
Sun, 18 Dec 2011 23:35:33 +0000 (00:35 +0100)
js/map.js

index 3c12015f01d31f1161abd191c682fc8290473ee1..1ce622642e52fe54dd09aeacdd42695381f0cb95 100644 (file)
--- a/js/map.js
+++ b/js/map.js
@@ -84,6 +84,7 @@ var gZoomTouchID;
 var gGeoWatchID;
 var gTrack = [];
 var gLastTrackPoint;
+var gCenterPosition = true;
 
 function initMap() {
   gCanvas = document.getElementById("map");
@@ -415,6 +416,12 @@ function startTracking() {
         // Coords spec: https://developer.mozilla.org/en/XPCOM_Interface_Reference/NsIDOMGeoPositionCoords
         gTrack.push({time: position.timestamp, coords: position.coords});
         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();
+        }
       },
       function(error) {
         // Ignore erros for the moment, but this is good for debugging.