Changed JSON serialization format
authorplehegar
Mon, 22 Aug 2011 15:50:09 -0400
changeset 11 0a609628a5ab
parent 10 c2d6cc0fe3c3
child 12 a40ef7b52b60
Changed JSON serialization format
Removed GPS speed
src/main/resources/scripts/tracker.js
--- a/src/main/resources/scripts/tracker.js	Mon Aug 22 15:49:08 2011 -0400
+++ b/src/main/resources/scripts/tracker.js	Mon Aug 22 15:50:09 2011 -0400
@@ -112,8 +112,8 @@
 
 function pushCoordinates(position) {
    coordinates[coordinates.length] =
-    [ position.timestamp, position.coords.longitude, position.coords.latitude, position.coords.altitude, position.coords.speed ];
-//    [ position.timestamp, position.coords.longitude, position.coords.latitude, position.coords.altitude ];
+//    [ position.timestamp, position.coords.longitude, position.coords.latitude, position.coords.altitude, position.coords.speed ];
+    [ position.timestamp, position.coords.longitude, position.coords.latitude, position.coords.altitude ];
 }
 
 function pause() {
@@ -126,17 +126,18 @@
 
 function getCoordinates() {
   if (coordinates.length > 0 && !running) {
-    var result = "";
+    var result = "[";
     var i = 0;
     while (i < coordinates.length) {
       var position = coordinates[i];
       var j = 1;
-      result += position[0];
+      result += "[" + position[0];
       while (j < position.length) result += "," + position[j++];      
-      result += " ";
+      result += "]";
       i++;
+      if (i < coordinates.length) result += ",";
     }
-    return result;
+    return result + "]";
   }
   return null;
 }