add a function for loading a track from the backend
authorRobert Kaiser <kairo@kairo.at>
Sun, 10 Dec 2017 20:32:24 +0000 (21:32 +0100)
committerRobert Kaiser <kairo@kairo.at>
Sun, 10 Dec 2017 20:32:24 +0000 (21:32 +0100)
js/map.js

index 242b2726f110a9f4633162f256941ee112a9c64d..6d1a6ce2c868584d2785d908a0db1fa946795f3c 100644 (file)
--- 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",