map = {
worldMap.select("#cities").remove()
worldMap.select("#connections").remove()
worldMap.select("#names").remove()
let nodes = data.nodes.filter(row=> row['rank'] === 'rank_' + index);
let edges = processEdges(nodes);
worldMap.append("g")
.attr("id", "connections")
.selectAll("paths")
.data(edges)
.enter()
.append("path")
.attr("d", (d) => {
let src = [d['src_lng'], d['src_lat']];
let trg = [d['trg_lng'], d['trg_lat']];
let toDraw = {type: "LineString", coordinates: [src, trg]};
let fullPath = mapPath(toDraw);
return fullPath;
})
.attr("stroke", (d) => {
if (d['new_route'] === 'True') {
return newRouteColor;
} else {
return oldRouteColor;
}
})
.attr("stroke-opacity", (d) => {
if (year === '2050') {
if (d['new_route'] === 'True') {
return 0.1;
} else {
return linkOpacity;
}
} else {
return linkOpacity;
}
})
.attr("fill", "none")
.attr("stroke-linecap", "round")
.attr("stroke-width", (d) => widthFxn(d[linkBase]));
worldMap.append("g")
.attr("id", "cities")
.selectAll("circle")
.data(nodes)
.join("circle")
.attr("transform", d => `translate(${mapProjection([d[lngBase], d[latBase]])})`)
.attr('r', d => radiusFxn(d[radBase]))
.attr('fill', d => rankScale(d['rank']))
.attr("stroke", 'white')
.attr("stroke-width", 0.5)
return worldMap.node()
}