map = {
let container = DOM.element('div',{ style: `width:${width}px;height:${width/1.2}px` });
yield container;
let map = L.map(container, { minZoom: 11, maxZoom: 14.5 })
let osmLayer = L.tileLayer('https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}@2x.png', {
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
map.setView([42.34, -71.1], 11.5);
let busLayer = L.geoJson(busRoutes, {
weight: 2.5,
filter: f => {
let r = f.properties.MBTA_ROUTE, filter = false;
for (let i = 0; i < ridershipData.length; i++) {
if (r == ridershipData[i].route) { filter = true; break; }
else { continue }
}
return filter;
},
onEachFeature: (f,l) => {
let ridership = getDataForFeature(f.properties.MBTA_ROUTE);
let r = +f.properties.MBTA_ROUTE;
let routename = (r<700) ? "Route " + r :
(r === 741) ? "Silver Line 1" :
(r === 742) ? "Silver Line 2" :
(r === 743) ? "Silver Line 3" :
"Silver Line 5";
l.bindPopup('<h4>'+routename + '</h4><br/>Currently carrying ' + (100-ridership) + '% of its pre-COVID19 ridership');
},
style: f => {
let r = f.properties.MBTA_ROUTE;
return { color: getColor(r) };
}
}).addTo(map);
let legend = L.control({position: 'bottomleft'})
legend.onAdd = function (map) {var div = L.DomUtil.create('div', 'legend'); return l};
legend.addTo(map);
}