|
var width = 960, |
|
height = 1160; |
|
|
|
|
|
|
|
var projection = d3.geo.albers() |
|
.center([9, 50]) |
|
.rotate([0, 0]) |
|
.scale(1200 * 5) |
|
.translate([width / 2, height / 2]); |
|
|
|
var path = d3.geo.path() |
|
.projection(projection); |
|
|
|
|
|
|
|
var svg = d3.select("body").append("svg") |
|
.attr("width", width) |
|
.attr("height", height); |
|
|
|
d3.json("de.json", function(error, de) { |
|
|
|
console.log(de); |
|
svg.append("path") |
|
.datum(topojson.object(de, de.objects.subunits)) |
|
.attr("class", function(d) { return "subunit"}) |
|
.attr("d", path); |
|
svg.append("path") |
|
.datum(topojson.object(de, de.objects.places)) |
|
.attr("d", path) |
|
.attr("class", "place"); |
|
|
|
svg.selectAll(".place-label") |
|
.data(topojson.object(de, de.objects.places).geometries) |
|
.enter().append("text") |
|
.attr("class", "place-label") |
|
.attr("transform", function(d) { return "translate(" + projection(d.coordinates) + ")"; }) |
|
.attr("dx", "0.75em") |
|
.text(function(d) { return d.properties.name; }); |
|
}); |
|
|
|
|