我已经使用d3.js创建了地图。我想在两个位置之间显示一条曲线。我能够显示一条线,但是有时它不能形成一条完美的曲线。对于某些线,这些线在地图后面(穿过子午线)弯曲到目的地。
这是演示问题的代码笔:https : //codepen.io/peeyush-pant/pen/WqbPax
还有一张图片:
这是我的投影数据:
var projection = d3.geoEquirectangular();
var path = d3.geoPath()
.projection(projection);
Run Code Online (Sandbox Code Playgroud)
这是我的界线:
arcGroup.selectAll("myPath")
.data(links)
.enter()
.append("path")
.attr("class", "line")
.attr("id", function (d, i) {
return "line" + i;
})
.attr("d", function (d) {
return path(d)
})
.style("fill", "none")
.style("stroke", '#fff787')
.style("stroke-width", 1.5);
Run Code Online (Sandbox Code Playgroud)
谢谢。