我想创建捷克共和国的世界地图。本文http://bl.ocks.org/mbostock/4060606的启发,我创造了这个
http://jsfiddle.net/1duds8tz/2/d3.js地理 - 渲染svg路径
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
谢谢.reverse() - 非常有用! – 2014-09-23 04:30:30
完美!我使用捷克统计办公室的KML文件,并通过QGIS(后来由http://mapbox.github.io/togeojson/)将其转换为GeoJSON。现在它的工作。非常感谢你。 – LutraLutra 2014-09-23 05:36:54