A very basic example of reandering Japan Atlas TopoJSON with D3.
Source: MLIT, 2017
A very basic example of reandering Japan Atlas TopoJSON with D3.
Source: MLIT, 2017
<!DOCTYPE html> | |
<style> | |
.city { | |
fill: #888; | |
stroke: #eee; | |
stroke-width: 0.08; | |
stroke-dasharray: 2,2; | |
} | |
</style> | |
<svg width="800" height="640"></svg> | |
<script src="https://d3js.org/d3.v4.min.js"></script> | |
<script src="https://d3js.org/topojson.v2.min.js"></script> | |
<script src="https://unpkg.com/d3-composite-projections@1.2.0"></script> | |
<script> | |
var svg = d3.select('svg'); | |
var projection = d3.geoConicEquidistantJapan(); | |
var path = d3.geoPath() | |
.projection(projection); | |
d3.json('japan-2017-topo.low.json', function(error, jp) { | |
if (error) throw error; | |
svg.append('path') | |
.datum(topojson.feature(jp, jp.objects.cities)) | |
.attr('class', 'city') | |
.attr('d', path); | |
svg.append('path') | |
.style('fill', 'none') | |
.style('stroke', '#ddd') | |
.style('stroke-width', '0.5px') | |
.attr('d', projection.getCompositionBorders()); | |
}); | |
</script> |