From: Robert Kaiser Date: Mon, 19 Dec 2011 01:00:05 +0000 (+0100) Subject: create hackish way to save GPX tracks and make the map only shift when we get enough... X-Git-Tag: legacy-preGL~85 X-Git-Url: https://git-public.kairo.at/?a=commitdiff_plain;h=99631a7543656fb58fe3c7f7913773d49630db03;p=lantea.git create hackish way to save GPX tracks and make the map only shift when we get enough outside the center --- diff --git a/index.html b/index.html index 8c889fc..2b4dd13 100644 --- a/index.html +++ b/index.html @@ -54,6 +54,8 @@ Z
+
Settings diff --git a/js/map.js b/js/map.js index 1ce6226..4cd4ea7 100644 --- 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); - 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) { diff --git a/js/ui.js b/js/ui.js index 0171e27..187a84d 100644 --- a/js/ui.js +++ b/js/ui.js @@ -62,3 +62,38 @@ function toggleSettings() { fs.style.display = "none"; } } + +function makeISOString(aTimestamp) { + // ISO time format is YYYY-MM-DDTHH:mm:ssZ + var tsDate = new Date(aTimestamp); + return tsDate.getUTCFullYear() + "-" + + (tsDate.getUTCMonth() < 10 ? "0" : "") + tsDate.getUTCMonth() + "-" + + (tsDate.getUTCDate() < 10 ? "0" : "") + tsDate.getUTCDate() + "T" + + (tsDate.getUTCHours() < 10 ? "0" : "") + tsDate.getUTCHours() + ":" + + (tsDate.getUTCMinutes() < 10 ? "0" : "") + tsDate.getUTCMinutes() + ":" + + (tsDate.getUTCSeconds() < 10 ? "0" : "") + tsDate.getUTCSeconds() + "Z"; +} + +function saveTrack() { + if (gTrack.length) { + var out = '' + "\n\n"; + out += '' + "\n"; + out += ' ' + "\n"; + out += ' ' + "\n"; + for (var i = 0; i < gTrack.length; i++) { + out += ' ' + "\n"; + if (gTrack[i].coords.altitude) { + out += ' ' + gTrack[i].coords.altitude + '' + "\n"; + } + out += ' ' + "\n"; + out += ' ' + "\n"; + gTrack[i].coords.latitude, gTrack[i].coords.longitude; + } + out += ' ' + "\n"; + out += ' ' + "\n"; + out += '' + "\n"; + var outDataURI = "data:application/octet-stream," + encodeURIComponent(out); + window.open(outDataURI, 'GPX Track'); + } +}