Вы можете предоставить geojson тип Sphere
для генератора пути:
Также поддерживается тип Sphere, который полезен для рендеринга контура земного шара;сфера не имеет координат.( документы )
Это выглядит следующим образом:
var outline = {type:"Sphere"}
И оно может быть передано непосредственно в генератор пути:
var context = d3.select("canvas").node().getContext("2d"),
projection = d3.geoNaturalEarth1()
.scale(70)
.translate([200,100])
path = d3.geoPath()
.context(context)
.projection(projection);
d3.json("https://unpkg.com/world-atlas@1/world/110m.json", function(error, world) {
if (error) throw error;
context.beginPath();
context.fillStyle = "lightgreen";
path(topojson.feature(world, world.objects.land));
context.fill();
context.beginPath();
context.strokeStyle = "#ccc";
path({type: "Sphere"})
context.stroke();
});
<canvas width="500" height="300"></canvas>
<script src="https://d3js.org/d3.v4.min.js"></script>
<script src="https://unpkg.com/topojson-client@3"></script>
Кроме того, имеется также d3.geoGraticule , который позволяет рисовать меридианы и параллели на регулярной основеинтервалы:
var context = d3.select("canvas").node().getContext("2d"),
projection = d3.geoNaturalEarth1()
.scale(70)
.translate([200,100])
path = d3.geoPath()
.context(context)
.projection(projection);
d3.json("https://unpkg.com/world-atlas@1/world/110m.json", function(error, world) {
if (error) throw error;
context.beginPath();
context.fillStyle = "lightgreen";
path(topojson.feature(world, world.objects.land));
context.fill();
context.beginPath();
context.strokeStyle = "#eee";
path(d3.geoGraticule10())
context.stroke();
context.beginPath();
context.strokeStyle = "#000";
path({type:"Sphere"})
context.stroke();
});
<canvas width="500" height="300"></canvas>
<script src="https://d3js.org/d3.v4.min.js"></script>
<script src="https://unpkg.com/topojson-client@3"></script>