ウィスコンシン州の静的でインタラクティブな地図を作成しようとしています。d3 v4の中心と回転投影
私はAlbers Equal Area Conic投影を使用していますが、.rotate
,.center
,.fitExtent
を試しましたが、これらをコードに追加するたびにマップは完全に消えます。
何が起こっている可能性がありますか?
は、ここでは、コードです:
var margin = {top: 20, left: 20, bottom: 20, right: 20}
height = 600- margin.top - margin.bottom,
width = 960 - margin.left - margin.right;
var svg2 = d3.select("#map2").append("svg")
.attr("height", height)
.attr("width", width)
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.right + ")");
d3.queue()
.defer(d3.json, "WiscCountiesNoProjection.json")
.await(ready);
var projection2 = d3.geoAlbers()
.translate([width/3, height/1])
.scale(4000)
var path2 = d3.geoPath()
.projection(projection2)
function ready (error, data) {
var counties = topojson.feature(data, data.objects.WiscCounties).features
svg2.selectAll(".counties")
.data(counties)
.enter().append("path")
.attr("class", "counties")
.attr("d", path2)
}
そして、ここで、それは次のようになります。