diff options
| author | Anson Bridges <bridges.anson@gmail.com> | 2023-11-10 00:00:10 -0500 |
|---|---|---|
| committer | Anson Bridges <bridges.anson@gmail.com> | 2023-11-10 00:00:10 -0500 |
| commit | 0e5d5ea7b26e55a6b83a10c53eada788d87428c2 (patch) | |
| tree | 4c32407e1e09c1f1063836461f305e41c427bccf /dashboard_website/static/js/dashboard.js | |
| parent | 04f7d71f25078d38a267d8e848bf556e8b6d3a0b (diff) | |
routes begin to show .
Diffstat (limited to 'dashboard_website/static/js/dashboard.js')
| -rw-r--r-- | dashboard_website/static/js/dashboard.js | 17 |
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}', { |
