diff --git a/templates/map.html b/templates/map.html
index 4960d1d..009a076 100644
--- a/templates/map.html
+++ b/templates/map.html
@@ -22,6 +22,15 @@ for (stop in stops){
let busIcon=L.icon({iconUrl:'static/bus.ico',iconSize:[32,32]})
let layerControl=L.control.layers().addTo(map);
let busLayers={},busMarkers={};
+function filterRoutes(wanted){
+ for(r in busLayers){
+ if(!wanted||wanted==r){
+ map.addLayer(busLayers[r])
+ } else{
+ map.removeLayer(busLayers[r])
+ }
+ }
+}
function updateMap(){
let routes={};
fetch("tarc.csv").then(response=>response.text()).then(csv=>{
@@ -30,7 +39,7 @@ function updateMap(){
p=parseInt(p);
t=new Date(t*1000).toLocaleTimeString("en-US",{hour12:false});
if(!busLayers[r]){busLayers[r]=L.layerGroup().addTo(map)}
- if(!busMarkers[id]){busMarkers[id]=L.marker([0,0]).addTo(busLayers[r])}
+ if(!busMarkers[id]){busMarkers[id]=L.marker([0,0],{icon:busIcon}).on('click',()=>filterRoutes(r)).addTo(busLayers[r])}
if(!routes[r]){routes[r]=[0,0]}
routes[r][0]++;
routes[r][1]+=p;
@@ -47,6 +56,7 @@ function updateMap(){
}
updateMap();
setInterval(updateMap,5000);
+map.on('click',()=>filterRoutes())
let locationMarker=L.marker([0,0]).addTo(map);
let locationRadius=L.circle([0,0]).addTo(map).bringToBack();