【发布时间】:2019-02-24 21:16:00
【问题描述】:
我使用here 所示的 geoNaturalEarth1() 在 d3 中创建了一张世界地图。我使用带有此投影的 geojson 世界地图来获取地图,如下面的代码所示。然而,这表明这些国家漂浮在没有边界的太空中。我想在地图投影周围画一个边框,让它看起来更像一张地图。边界将是平坦的顶部/底部、弯曲的侧面,如投影图像中所示。这可能吗?我该怎么做?
var projection = d3.geoNaturalEarth1()
.translate([w/2, h/2])
.scale(247)
.center([0,0]);
var path = d3.geoPath().projection(projection);
d3.json('map.geojson').then(function(world) {
svg.selectAll(".emissions_path")
.data(world.features)
.enter().append("path")
.attr('fill', '#fff')
.attr("d", path)
.style('stroke', 'black')
.style('stroke-width', '0.5px');
【问题讨论】:
标签: javascript d3.js maps