map = {
const mapWidth = 900;
const mapHeight = 1000;
const projection = d3.geoTransverseMercator()
.rotate([90 + 10 / 60, -36 - 40 / 60])
.fitSize([mapWidth,mapHeight], chicago_boundaries);
var map = d3.create('svg')
.attr('width', 900)
.attr('height', mapHeight)
.attr('id', 'map');
var path = d3.geoPath()
.projection(projection);
var chicago = map.append('path')
.datum(chicago_boundaries)
.attr('d', path)
.style('stroke', 'black')
.style('fill', 'none');
var radius_scale = d3.scaleLinear().domain([0,120]).range([3, 20])
var stations = map
.selectAll('circle.station')
.data(preds_stats.filter(d => d.Line == lines.get(line_choice) &
d.Prediction_Count > 100 &
d.dir_code == direction.get(direction_choice) &
d.Hour == hour_slider &
d.stationOrder2 - d.stationOrder == 1))
.join('circle')
.attr('class', 'station')
.attr('cx', (d) => projection([d.stop_lon, d.stop_lat])[0])
.attr('cy', (d) => projection([d.stop_lon, d.stop_lat])[1])
.attr('r', function(d){
if(get_pred_std.get(d.stationOrder) <= 30){
return 5;
}else if(get_pred_std.get(d.stationOrder) > 30 &
get_pred_std.get(d.stationOrder) <= 60){
return 10;
}else{
return 15;
}})
.attr('fill-opacity', 0.5)
.style('fill', line_choice)
.style('stroke', function(d){if(get_pred_std.get(d.stationOrder) >= 120){
return 'red';
}else if(d.stop_name == station_start){
return 'black';
}})
.style('stroke-width', 3)
.append('title')
.text(d => d.stop_name + ' - Median travel time to next stop: ' + get_pred_median.get(d.stationOrder) + '\n')
.append('title')
.text(d => d.stop_name + ' - Median standard deviation to next stop: ' + get_pred_std.get(d.stationOrder) + ' seconds');
map.append('rect')
.attr('width', 900)
.attr('height', 20)
.attr('fill', 'white');
map.append('text')
.attr('transform', 'translate(10, 17)')
.attr('font-weight', 400)
.style('font-size', '20px')
.text('Map Showing Prediction Standard Deviation Between Stations');
return map.node();
}