function drawWorldMap(svg, options = {}) {
options = addDefaults(options, {
width: width,
height: 500,
projection: d3.geoNaturalEarth2(),
colorSea: '#08f',
colorGraticule: '#ccc',
funcCountryDataToColor: function(d) {
if (d.properties.ISO3 === 'LKA') {
return '#f00';
}
if (['IND', 'SOM', 'THA', 'ATA'].includes(d.properties.ISO3)) {
return '#fcc';
}
return '#888';
}
});
const path = d3.geoPath(options.projection);
svg
.append("g")
.append("path")
.datum(d3.geoGraticule10())
.attr("class", "graticule")
.attr("d", path)
.attr("clip-path", "url(#clip)")
.style('fill', "none")
.style('stroke', options.colorGraticule)
.style('stroke-width', .8)
.style('stroke-opacity', .5)
.style('stroke-dasharray', 2);
const countries = topojson.feature(world, world.objects.world_countries_data)
.features;
svg
.append("g")
.selectAll("path")
.data(countries)
.join("path")
.attr("fill", options.funcCountryDataToColor)
.attr("d", path);
}