From 0e5d5ea7b26e55a6b83a10c53eada788d87428c2 Mon Sep 17 00:00:00 2001 From: Anson Bridges Date: Fri, 10 Nov 2023 00:00:10 -0500 Subject: routes begin to show . --- dashboard_website/static/js/dashboard.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'dashboard_website/static/js/dashboard.js') 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}', { -- cgit v1.2.3