map = {
const svg = d3.create("svg").attr("width", width).attr("height", height);
const viz = svg.append("g");
const path = d3.geoPath(clipped);
const outlinePath = viz
.append("path")
.datum(outline)
.attr("id", "outline")
.attr("stroke", "#aaa")
.attr("opacity", 1)
.attr("stroke-width", 1)
.attr("stroke-linejoin", "round")
.attr("fill", "#eee")
.attr("d", path)
.attr("pointer-events", "none");
const landPath = viz
.append("g")
.attr("id", "land")
.selectAll("path")
.data(ne_110m_land.features)
.join("path")
.attr("id", (d) => d.properties.formal_en)
.attr("d", path)
.attr("fill", "#fff")
.attr("fill-opacity", 1)
.attr("stroke", "#043B62")
.attr("stroke-alignment", "inner");
const poli = viz
.append("g")
.attr("id", "land")
.selectAll("path")
.data(unrotatedPolygons.features.filter((d, i) => i === selectedId))
.join("path")
.attr("d", path)
.attr("fill", "none")
.attr("fill-opacity", 1)
.attr("stroke", "red")
.attr("stroke-alignment", "inner");
const projCentroids = unrotatedPolygons.features.map((d) =>
projection(d3.geoCentroid(d))
);
const face = unrotatedPolygons.features[selectedId];
const centroid = d3.geoCentroid(face);
const northRef = [centroid[0], centroid[1] + 10];
const [cx, cy] = clipped(centroid);
const [nx, ny] = clipped(northRef);
const cent = viz
.append("g")
.append("circle")
.attr("cx", cx)
.attr("cy", cy)
.attr("r", 5)
.attr("fill", "blue")
.attr("stroke", "none");
viz
.append("line")
.attr("x1", cx)
.attr("y1", cy)
.attr("x2", nx)
.attr("y2", ny)
.attr("stroke", "black")
.attr("stroke-width", 2);
return svg.node();
}