map = svg`<svg viewBox="0 0 ${width} ${height}" style="width:100%;height:auto;background-color:#000">
${tile().map(d => {
let w2 = width/2
let h2 = height/2
const buildings = svg`<g fill="#000">`;
const water = svg`<path stroke="#64b5f6" fill="none" stroke-width="5.5" stroke-linecap="round" stroke-linejoin="round">`;
const waterfill = svg`<path stroke="#64b5f6" fill="#64b5f6" stroke-width="1.5">`;
console.log(d)
fetch(`https://tile.nextzen.org/tilezen/vector/v1/256/all/${d.z}/${d.x}/${d.y}.json?api_key=${key}&foo=bar`)
.then(response => response.json())
.then(data => {
if(data.water.features.length) { console.log(data.water.features) }
d3.select(buildings).selectAll("path.building").data(data.buildings.features)
.enter().append("path").classed("building", true)
.attr("d", path)
.attr("fill", function(d) {
let c = path.centroid(d)
let dist2 = (w2 - c[0])*(w2 - c[0]) + (h2 - c[1])*(h2 - c[1])
return colorScale(dist2)
})
water.setAttribute("d", path({
type: "FeatureCollection",
features: data.water.features
.filter(d => d.properties.boundary)
}));
waterfill.setAttribute("d", path({
type: "FeatureCollection",
features: data.water.features.filter(d =>
(d.properties.kind == "water"
&& d.properties.area > 500000)
)
}));
});
return svg`${buildings}${water}${waterfill}`;
})}</svg>`