我想使用d3显示澳大利亚地图。我可以将地图居中,但无法正确旋转它以使其正确显示。
下面是相关代码:
var projection = d3.geo.albers().scale(1).translate([0,0]);
var path = d3.geo.path().projection(projection);
var bounds = path.bounds(topojson.feature(dataSet, dataSet.objects.abs_aus_ced_2007));
var scale = 0.95 /Math.max((bounds[1][0] - bounds[0][0])/width, (bounds[1][1] - bounds[0][1])/height);
var translate = [(width - scale * (bounds[1][0] + bounds[0][0])) / 2, (height - scale * (bounds[1][1] + bounds[0][1])) / 2];
projection.scale(scale).translate(translate);
path = d3.geo.path().projection(projection);
地图顺时针旋转了约80度。我无法找出如何纠正旋转以正确显示地图。
任何提示都将非常棒!