map = {
const svg = d3
.create("svg")
.attr("viewBox", [0, 0, width, height])
.style("width", "100%")
.style("height", "auto");
svg
.append("g")
.append("path")
.datum(sphere)
.attr("class", "graticuleOutline")
.attr("d", path)
.style("fill", "#9ACBE3");
svg
.append("g")
.append("path")
.datum(d3.geoGraticule10())
.attr("class", "graticule")
.attr("d", path)
.attr("clip-path", "url(#clip)")
.style("fill", "none")
.style("stroke", "white")
.style("stroke-width", 0.8)
.style("stroke-opacity", 0.5)
.style("stroke-dasharray", 2);
svg
.append("path")
.datum(countries)
.attr("fill", "#d4c9b2")
.attr("stroke", "white")
.attr("stroke-width", 0.4)
.attr("d", path);
// Coast
svg
.append("path")
.datum(coast)
.attr("fill", "none")
.attr("stroke", "#6caee0")
.attr("stroke-width", 1.5)
.attr("d", path);
// Route
const line = d3
.line()
.x((d) => d.x)
.y((d) => d.y)
.curve(c.value);
const route = svg
.append("path")
.datum(data)
.attr("d", line)
.attr("stroke", "#8c2a79")
.attr("stroke-width", 3)
.attr("stroke-dasharray", 4)
.attr("fill", "none");
// Steps
const steps = svg
.append("g")
.selectAll("circle")
.data(data)
.join("circle")
.attr("cx", (d) => d.x)
.attr("cy", (d) => d.y)
.attr("stroke", "#8c2a79")
.attr("stroke-width", 3)
.attr("fill", "#d4c9b2")
.attr("r", 6);
// Labels
const labels = svg
.append("g")
.selectAll("text")
.data(data)
.join("text")
.attr("x", (d, i) => d.x + dx[i])
.attr("y", (d, i) => d.y + dy[i])
.attr("font-family", "sans-serif")
.attr("fill", "#8c2a79")
.attr("text-anchor", "middle")
.text((d) => d.id);
// Texts
svg
.append("rect")
.attr("x", 0)
.attr("y", 0)
.attr("width", width)
.attr("height", 70)
.attr("fill", "white")
.attr("fill-opacity", 0.5);
svg
.append("text")
.attr("x", 20)
.attr("y", 47)
.attr("font-weight", "bold")
.attr("font-family", "sans-serif")
.attr("fill", "#8c2a79")
.style("font-size", "37px")
.text(title);
svg
.append("g")
.selectAll("text")
.data(note)
.join("text")
.attr("transform", (d, i) => `translate(${20},${i * 20})`)
.attr("dy", 110)
.text((d) => d)
.attr("font-family", "sans-serif")
.attr("fill", "#8c2a79")
.style("font-size", "17px");
svg
.append("svg:a")
.attr(
"xlink:href",
"https://twitter.com/neocartocnrs/status/1318807216145813505"
)
.append("svg:text")
.text("[view original map]")
.attr("dy", 210)
.attr("dx", 20)
.attr("font-family", "sans-serif")
.attr("fill", "#8c2a79")
.style("font-size", "14px");
svg
.append("path")
.attr("d", signature)
.attr("transform", "translate(925,865) scale(1.2) ")
.attr("fill", "#8c2a79")
.attr("fill-opacity", 0.75);
// Dot Motion
const dot = svg.append("g");
while (true) {
const length = route.node().getTotalLength(),
int = d3.interpolate(0, length),
x = (t) => route.node().getPointAtLength(int(t)).x,
y = (t) => route.node().getPointAtLength(int(t)).y;
dot
.selectAll("circle")
.data([data[0]])
.join("circle")
.attr("cx", (d) => d.x)
.attr("cy", (d) => d.y)
.attr("fill", "#8c2a79")
.attr("r", 10)
.transition()
.delay(500)
.duration(10000)
.attrTween("cx", () => x)
.attrTween("cy", () => y);
yield svg.node();
await Promises.tick(12000);
}
//return svg.node();
}