【发布时间】:2014-09-22 10:59:18
【问题描述】:
我想创建捷克共和国的等值线地图。受这篇文章http://bl.ocks.org/mbostock/4060606的启发,我创建了这个
http://jsfiddle.net/1duds8tz/2/
var width = 960;
var height = 500;
var svg = d3.select("body").append("svg").attr("width", width).attr("height", height);
var offset = [width / 2, height / 2];
var projection = d3.geo.mercator().scale(6000).center([15.474, 49.822]).translate(offset);
var path = d3.geo.path().projection(projection);
queue().defer(d3.json, "..map.geojson").await(ready);
function ready(error, reg) {
var group = svg.selectAll("g").data(reg.features).enter().append("g");
group.append("path").attr("d", path).attr("fill", "none").attr("stroke", "#222");
}
当我尝试用一些颜色填充 svg 路径时,我结束了这个
http://jsfiddle.net/1duds8tz/3/
group.append("path").attr("d", path).attr("fill", "red").attr("stroke", "#222");
路径 d 属性中有奇数值。 我的 GeoJSON 数据一定有问题,但我不知道出了什么问题。
一切看起来都在这里:https://gist.github.com/anonymous/4e51227dd83be8c2311d
【问题讨论】: