Skip to content

Instantly share code, notes, and snippets.

@nobuf
Last active July 15, 2017 06:53
Show Gist options
  • Save nobuf/303d300f57c5c2b6091d2bb01279212a to your computer and use it in GitHub Desktop.
Save nobuf/303d300f57c5c2b6091d2bb01279212a to your computer and use it in GitHub Desktop.
A simple map with Japan Atlas TopoJSON
<!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>
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment