0

我想使用 d3.js 显示中国地图,但是当我成功地将 mydata 转换为 geojson 时,数据无法正确可视化。我认为原因可能是投影。你能帮我克服它吗,想想你!

<script>
var width = 960,
height = 500;
var proj = d3.geo.mercator();
var path = d3.geo.path().projection(proj);
proj.translate([width / 2, height / 2]);
proj.scale(5000);
proj.center([105, 35]);

var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height);

d3.json("mydata.json", function (json) {
    svg.selectAll("path").data(json.features).enter().append("path").attr("d", path);
});

mydata.json: http ://mysnspace.sinaapp.com/mydata.json

4

1 回答 1

0

我使用投影等距矩形而不是墨卡托并正确生成了我的。

布赖恩

于 2013-06-24T03:53:17.077 回答