globe = {
let showGraticule = true;
let height = 600
const sensitivity = 75
let yValues = geoTopology.arcs.flat().map(c => c[1]);
let minY = _.min(yValues);
let maxY = _.max(yValues);
let projection = d3.geoMiller().fitWidth(window.innerWidth, ({type: "Sphere"}));
const initialScale = projection.scale()
let path = d3.geoPath().projection(projection)
const svg = d3.select(DOM.svg(width, height))
let globe = svg.append("circle")
.attr("fill", colors.water)
.attr("stroke", "#none")
.attr("stroke-width", "0")
.attr("cx", width/2)
.attr("cy", height/2)
.attr("r", initialScale)
let countries = topojson.feature(geoTopology, geoTopology.objects.land).features
let borders = topojson.mesh(geoTopology, geoTopology.objects.regions, (a, b) => a !== b);
let graticule = d3.geoGraticule()
if (showGraticule) {
svg.append("path")
.datum(graticule())
.attr("class", "graticule")
.attr("d", path)
.attr('fill', 'none')
.attr('stroke', colors.graticules)
.attr('stroke-width', '0.5px');
}
let country = svg.selectAll("country")
.data(countries)
.enter().append("path")
.attr("class", "country")
.attr("d", path)
.style("fill", colors.land);
svg.append("path")
.datum(borders)
.attr("d", path)
.attr("class", "borders")
.style("fill", "none")
.style("stroke", colors.borders)
.style("stroke-width", "0.3px")
svg.call(d3.drag().on('drag', (event) => {
const rotate = projection.rotate()
const k = sensitivity / projection.scale()
projection.rotate([
rotate[0] + event.dx * k,
rotate[1]
])
path = d3.geoPath().projection(projection)
svg.selectAll("path").attr("d", path)
}))
.call(d3.zoom().on('zoom', (event) => {
if(event.transform.k > 0.3) {
projection.scale(initialScale * event.transform.k)
path = d3.geoPath().projection(projection)
svg.selectAll("path").attr("d", path)
globe.attr("r", projection.scale())
}
else {
event.transform.k = 0.3
}
}))
return svg.node()
}