我在使用 topojson 绘制委内瑞拉时遇到了问题。我从以下网址获得了委内瑞拉的 GeoJson 数据:http ://code.highcharts.com/mapdata/countries/ve/ve-all.geo.json
之后,我尝试使用 topojson 控制台实用程序并将其导入此站点: http: //www.mapshaper.org/并将其导出为 topojson。我无法渲染地图。这是我的代码:
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="http://d3js.org/topojson.v1.min.js"></script>
<script>
var width = 960,
height = 1160;
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height);
d3.json("venezuela.json", function(error, ve) {
var path = d3.geo.path();
svg.append("path")
.datum(topojson.feature(ve, ve.objects['ve-all.geo']))
.attr("d", d3.geo.path().projection(d3.geo.mercator()));
});
</script>
</body>
</html>
我不确定问题是否与从 geojson 到 topojson 的转换或其他问题有关。
太感谢了,
里卡多