From 57ee3e06c1c005f34297f9b9d1f7e6211ca30607 Mon Sep 17 00:00:00 2001 From: Robert Kaiser Date: Sun, 10 Dec 2017 21:32:24 +0100 Subject: [PATCH] add a function for loading a track from the backend --- js/map.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/js/map.js b/js/map.js index 242b272..6d1a6ce 100644 --- a/js/map.js +++ b/js/map.js @@ -1230,6 +1230,24 @@ function clearTrack() { drawTrack(); } +function loadTrack(aTrackId) { + fetchBackend("track_json?id=" + encodeURIComponent(aTrackId), "GET", null, + function(aResult, aStatusCode) { + if (aStatusCode >= 400 || !aResult) { + console.log("loading track failed: " + aStatusCode + ", result: " + aResult.message); + } + else { + console.log("loading track with " + aResult.length + " points."); + gTrack = aResult; + for (var i = 0; i < gTrack.length; i++) { + try { gTrackStore.push(gTrack[i]); } catch(e) {} + } + drawTrack(); + } + } + ); +} + var gTileService = { objStore: "tilecache", -- 2.43.0