summaryrefslogtreecommitdiff
path: root/dashboard_website/static/js
diff options
context:
space:
mode:
Diffstat (limited to 'dashboard_website/static/js')
-rw-r--r--dashboard_website/static/js/dashboard.js17
1 files changed, 15 insertions, 2 deletions
diff --git a/dashboard_website/static/js/dashboard.js b/dashboard_website/static/js/dashboard.js
index c1f1428..0248844 100644
--- a/dashboard_website/static/js/dashboard.js
+++ b/dashboard_website/static/js/dashboard.js
@@ -9,8 +9,9 @@ var visited_clues_m = L.layerGroup([]); // all clues
var unvisited_clues_m = L.layerGroup([]); // subset of all clues - unvisited clues
var destination_clues_m = L.layerGroup([]); // clues bikers are currently destined for
var bikes_m = L.layerGroup([]); // bike markers
+var routes_m = L.layerGroup([]); // polyline routes
-var homemarker, homebase, clues, clue_rels, bikes, previewmarker;
+var homemarker, homebase, clues, clue_rels, bikes, routes, previewmarker;
var latest_timestamp = -1; // initially -1, otherwise set to value given by server in last successful info update
@@ -58,6 +59,13 @@ function drawRoute(route_coords_osrm, team_color) {
}
var route = new L.polyline(route_coords_osrm, {color: team_color}).addTo(map);
}
+function drawRoutes() {
+ for (var i = 0; i < routes['clusters'].length; i++){
+ if(routes['clusters'][i].length > 0){
+ drawRoute(routes['clusters'][i], i%2 == 0 ? 'red' : 'yellow');
+ }
+ }
+}
function updateBikeStatus(){
var table = document.getElementById("bike-teams-table");
@@ -170,6 +178,11 @@ function requestLatestInfo(){
drawClues();
updateClueStats();
}
+ // process routes
+ if(json['routes_changed']){
+ routes = json['routes'];
+ drawRoutes();
+ }
}
fetch(host+'/getLatestInfo', {
method: "POST",
@@ -192,7 +205,7 @@ var clockINterval = window.setInterval(function(){
// RUN ON PAGE LOAD
window.onload = function() {
- clues = {}; bikes = {};
+ clues = {}; bikes = {}; routes = {};
map = L.map('map').setView([42.3626081,-71.0620591], 13);
L.tileLayer('https://tiles.stadiamaps.com/tiles/alidade_smooth_dark/{z}/{x}/{y}{r}.{ext}', {