map = {
const svg = d3.create("svg")
.attr("viewBox", [0, 0, width, height]);
const g = svg.append("g");
const circuitLine = g.append("g")
.attr("class", "circuit")
.selectAll("path")
.data(centerline.features)
.enter().append("path")
.attr("d", path)
.style("fill", "none")
.style("stroke", "#000")
.style("stroke-width", "2px")
let displayCircuitLinePoints = false;
if (displayCircuitLinePoints) {
svg.selectAll(".point")
.data(centerline.features[0].geometry.coordinates)
.join("circle")
.attr("r", 2)
.attr("transform", function(d) { return 'translate(' + projection(d)[0] + ',' + projection(d)[1] + ')'; });
}
const circle = svg.append("circle")
.attr("r", 10)
.attr("transform", "translate(" + centerline.features[0].geometry.coordinates[0] + ")")
.style("fill", "#E10600")
.style("stroke", "#fff")
.style("stroke-width", "3px")
transition();
function transition() {
circle.transition()
.duration(10000)
.attrTween("transform", translateAlong(circuitLine.node()))
.end()
.then(transition);
}
function translateAlong(circuitLine) {
var l = circuitLine.getTotalLength();
return function(d, i, a) {
return function(t) {
var p = circuitLine.getPointAtLength(t * l);
return "translate(" + p.x + "," + p.y + ")";
};
};
}
return svg.node();
}