Skip to content

Commit 6ce7f7d

Browse files
redraw vehicles only when there is a new position
1 parent 1504259 commit 6ce7f7d

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

js/tracker.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,9 @@ function updateVehicleInfo(index, newPosition) {
574574
var c = $('.vehicle'+index+' .graph');
575575
drawAltitudeProfile(c.get(0), c.get(1), vehicles[index].alt_list, vehicles[index].alt_max);
576576

577+
// mark vehicles as redrawn
578+
vehicles[index].updated = false;
579+
577580
return true;
578581
}
579582

@@ -896,7 +899,8 @@ function addPosition(position) {
896899
alt_max: 100,
897900
graph_data_updated: false,
898901
graph_data: [],
899-
graph_yaxes: []
902+
graph_yaxes: [],
903+
updated: false
900904
};
901905

902906
// deep copy yaxes config for graph
@@ -993,15 +997,18 @@ function addPosition(position) {
993997

994998
vehicle.curr_position = position;
995999
graphAddLastPosition(vehicle_index);
1000+
vehicle.updated = true;
9961001
}
9971002
}
9981003
} else {
1004+
vehicle.updated = true;
9991005
vehicle.positions.push(new_latlng);
10001006
vehicle.num_positions++;
10011007
vehicle.curr_position = position;
10021008
graphAddLastPosition(vehicle_index);
10031009
}
10041010
} else { // if car
1011+
vehicle.updated = true;
10051012
vehicle.curr_position = position;
10061013
}
10071014

@@ -1375,7 +1382,7 @@ function update(response) {
13751382

13761383
if(listScroll) listScroll.refresh();
13771384
}, 400*i);
1378-
} else {
1385+
} else if(vehicles[i].updated) {
13791386
updatePolyline(i);
13801387
updateVehicleInfo(i, vehicles[i].curr_position);
13811388

0 commit comments

Comments
 (0)