generateMap = ({ geoJSON, chartProjection, pathGroup, mapType }) => {
let path = d3.geoPath()
.projection(chartProjection);
pathGroup.selectAll("path")
.data( geoJSON.features, d => d.properties.GEOID)
.join(
enter => enter.append("path")
.attr("d", path)
.attr("class", `${mapType}-path`)
.style("opacity", 1.0)
.style("stroke", "black")
.style("stroke-width", mapType !== "tract" && showCityBoundaries ? 0.5 : 0)
.style("fill-opacity", d => {
if (mapType !== "tract") {
return 0;
}
return d.properties.total_commuters > 0 ? 1.0*d.properties.main_city_commuters / d.properties.total_commuters : 0.0;
})
.on("mouseover", function(e, d) {
if (mapType !== "tract") {
d3.select(this)
.attr("prev-stroke-width", d3.select(this).style("stroke-width"))
.style("stroke-width", 1)
toolTip.show(d, this);
}
})
.on("mouseout", function(e, d) {
if (mapType !== "tract") {
console.log("enter", showCityBoundaries)
d3.select(this).style("stroke-width", d3.select(this).attr("prev-stroke-width"))
toolTip.hide();
}
})
.style("fill", d => {
if (mapType === "state") {
return "white";
}
return mapColor
}),
update => update
.style("stroke-width", mapType !== "tract" && showCityBoundaries ? 0.5 : 0),
exit => exit.remove()
);
};