From: Robert Kaiser Date: Sun, 10 Dec 2017 20:32:24 +0000 (+0100) Subject: add a function for loading a track from the backend X-Git-Tag: production~15 X-Git-Url: https://git-public.kairo.at/?p=lantea.git;a=commitdiff_plain;h=57ee3e06c1c005f34297f9b9d1f7e6211ca30607;ds=sidebyside add a function for loading a track from the backend --- 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",