Skip to content

Instantly share code, notes, and snippets.

@katsumitakano
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save katsumitakano/9525160 to your computer and use it in GitHub Desktop.
Save katsumitakano/9525160 to your computer and use it in GitHub Desktop.
Japan Map [TopoJSON]
<!doctype html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>日本地図を描画する</title>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="http://d3js.org/topojson.v0.min.js"></script>
</head>
<body>
<script>
var width = 960;
var height = 500;
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height);
d3.json("japan.topojson", function (error, jpn) {
var projection = d3.geo.mercator()
.center([137, 34])
.scale(900)
.translate([width / 2, height / 2]);
var path = d3.geo.path()
.projection(projection);
var features = topojson.object(jpn, jpn.objects.japan);
svg.selectAll("path")
.data(features.geometries)
.enter()
.append("path")
.attr("stroke", "white")
.attr("stroke-width", "0.5")
.attr("d", path);
});
</script>
</body>
</html>
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