1

我正在尝试使用 Open Street Maps 中的数据渲染投影。我从这里下载了瑞典交通文件并将建筑物 shapefile 转换为 topojson。这是一个摘录:

{"type":"Topology","transform":{"scale":[0.0013154551155115512,0.0013336730673067306],"translate":[11.0320167,55.3382768]},"objects":{"buildings":{"type":"GeometryCollection","geometries":[{"type":"Polygon","arcs":[[0,1,2]]},{"type":null},{"type":"Polygon","arcs":[[3]]}...

我的目标是创建斯德哥尔摩建筑物的地图,并具有以下 D3 代码:

<script>

var width = 960,
    height = 500;

var projection = d3.geo.albers()
    .translate(width/2, height/2)
    .scale(20000)
    .rotate([-18.0365, 0])
    .center([0, 59.3115]);

var path = d3.geo.path()
    .projection(projection);

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

d3.json('buildings.json', function(err, city) {
    svg.append("path")
        .datum(topojson.object(city, city.objects.buildings.geometries))
        .attr("d", path);
}); 

</script>

但是,这只会加载一个空白页面,并且 javascript 控制台中没有错误。不知道下一步该去哪里,任何帮助将不胜感激。谢谢,汤姆

4

0 回答 0