mapbox = {
const root = DOM.element("div", {
style: `width:${width}px; height:${width / 1.6}px`
});
yield root;
const map = new mapboxgl.Map({
container: root,
style: "mapbox://styles/mapbox/light-v10",
center: [-120.56827, 37.88536],
zoom: 7,
projection: {
name: "lambertConformalConic",
center: [-120, 37],
parallels: [37 + 4 / 60, 38 + 26 / 60]
}
});
map.on("load", () => {
map.addSource("acs-2020-ca-sp3-tracts", {
type: "geojson",
data: caSP3Tracts
});
map.addLayer({
id: "acs-2020-ca-sp3-tracts",
type: "fill",
source: "acs-2020-ca-sp3-tracts",
layout: {},
paint: {
"fill-color": [
"let",
"value",
["*", ["/", ["get", "B02001004"], ["get", "B02001001"]], 100],
[
"case",
[">", ["var", "value"], 20],
"#f2f0f7",
[">", ["var", "value"], 10],
"#54278f",
[">", ["var", "value"], 5],
"#756bb1",
[">", ["var", "value"], 1],
"#9e9ac8",
[">=", ["var", "value"], 0],
"#cbc9e2",
"transparent"
]
],
"fill-opacity": 0.8
}
});
map.addLayer({
id: "acs-2020-ca-sp3-tracts-outline",
type: "line",
source: "acs-2020-ca-sp3-tracts",
layout: {},
paint: {
"line-color": [
"let",
"totalPop",
["get", "B02001001"],
["match", ["var", "totalPop"], 0, "transparent", "#fff"]
],
"line-width": 0.5
}
});
});
}