map = {
const svg = d3.create("svg")
.attr("viewBox", [0, 0, width, height]);
let path = d3.geoPath(projection);
let defs = svg.append("defs");
defs.append("path")
.attr("id", "outline")
.attr("d", path(outline));
defs.append("clipPath")
.attr("id", "clip")
.append("use")
.attr("xlink:href", new URL("#outline", location));
let gra=svg.append("path")
.attr("d", path(graticule))
.attr("stroke", "#ccc")
.attr("fill", "none");
let g = svg.append("g")
.attr("clip-path", `url(${new URL("#clip", location)})`);
g.selectAll('path')
.data(countries.features)
.enter().append('path')
.attr('d', path)
.attr('stroke', lineColor)
.attr('stroke-width', 1).attr('fill', landColor)
.on('mouseover', function (d) {
d3.select(this)
.attr('opacity',0.7)
.attr("stroke", '#fffff0')
.attr("stroke-width", 5);
})
.on('mouseout', function (d) {
d3.select(this)
.attr('opacity',1)
.attr("stroke", lineColor)
.attr("stroke-width", 1);
});
svg.append("use")
.attr("xlink:href", new URL("#outline", location))
.attr("stroke", "#000")
.attr("fill", "none");
function render() {
console.log("Render")
path = d3.geoPath(projection)
g.attr("d", path)
gra.attr('d',path(graticule))
}
svg
.call(drag(projection)
.on("drag.render", () => render()))
.call(() => render())
return svg.node();
}