{
let this_map = document.getElementById("map");
this_map.innerHTML = "";
let width = d3.select("#map").node().getBoundingClientRect().width + 4;
let height = 500 + 4;
const sensitivity = 75;
let projection = d3
.geoOrthographic()
.scale(250)
.center([0, 0])
.rotate([-5, 0])
.translate([width / 2, height / 2]);
const initialScale = projection.scale();
let path = d3.geoPath().projection(projection);
let svg = d3
.select("#map")
.append("svg")
.attr("width", width)
.attr("height", height);
let globe = svg
.append("circle")
.attr("fill", "lightblue")
.attr("cx", width / 2)
.attr("cy", height / 2)
.attr("r", initialScale);
let data = await world_json.json();
svg
.append("g")
.attr("class", "countries")
.selectAll("path")
.data(data.features)
.enter()
.append("path")
.attr("class", (d) => "country_" + d.properties.name.replace(" ", "_"))
.attr("d", path)
.attr("fill", "white")
.style("stroke", "white")
.style("stroke-width", 0.3);
svg
.append("circle")
.attr("fill", "none")
.attr("stroke", "#000")
.attr("stroke-width", "1")
.attr("cx", width / 2)
.attr("cy", height / 2)
.attr("r", initialScale);
d3.timer(function (elapsed) {
const rotate = projection.rotate();
const k = sensitivity / projection.scale();
projection.rotate([rotate[0] - 1 * k, rotate[1]]);
path = d3.geoPath().projection(projection);
svg.selectAll("path").attr("d", path);
}, 200);
}