Azimuthal Equidistant projection done with Canvas.
Using the type "Sphere" to get the outline instead of graticule.outline()
.
license: mit | |
border: none | |
height: 1000 |
Azimuthal Equidistant projection done with Canvas.
Using the type "Sphere" to get the outline instead of graticule.outline()
.
<!DOCTYPE html> | |
<meta charset="utf-8" /> | |
<body> | |
<script src="https://d3js.org/d3.v3.min.js" charset="utf-8"></script> | |
<script src="https://d3js.org/topojson.v1.min.js"></script> | |
<script src="https://unpkg.com/[email protected]/rbush.js"></script> | |
<script src="https://unpkg.com/[email protected]/d3.geo.projection.min.js"></script> | |
<script src="https://unpkg.com/[email protected]/spam.min.js"></script> | |
<script type='text/javascript'> | |
var graticule = d3.geo.graticule(); | |
d3.json("https://unpkg.com/[email protected]/world/50m.json", function(err, d) { | |
topojson.presimplify(d); | |
var map = new StaticCanvasMap({ | |
element: "body", | |
width: 960, | |
height: 1000, | |
projection: d3.geo | |
.azimuthalEquidistant() | |
.scale(150) | |
.translate([960 / 2, 1000 / 2]) | |
.clipAngle(180 - 4e-3) | |
.precision(0.1), | |
data: [ | |
{ | |
features: topojson.feature(d, d.objects["countries"]), | |
static: { | |
prepaint: function(parameters) { | |
parameters.context.beginPath(); | |
parameters.path(graticule()); | |
parameters.context.lineWidth = 0.5; | |
parameters.context.strokeStyle = "rgb(170,170,170)"; | |
parameters.context.stroke(); | |
parameters.context.beginPath(); | |
parameters.path({ type: "Sphere" }); | |
parameters.context.lineWidth = 1.5; | |
parameters.context.strokeStyle = "rgb(30,30,30)"; | |
parameters.context.stroke(); | |
}, | |
paintfeature: function(parameters, d) { | |
parameters.context.lineWidth = 0.5; | |
parameters.context.strokeStyle = "rgb(255,255,255)"; | |
parameters.context.stroke(); | |
parameters.context.fillStyle = "#111"; | |
parameters.context.fill(); | |
} | |
} | |
} | |
] | |
}); | |
map.init(); | |
}); | |
</script> |