为什么渲染此SVG地图会导致我的浏览器崩溃?

时间:2013-05-24 23:54:52

标签: d3.js gis topojson

我正在尝试使用this shapefile与D3(和topojson)制作干旱地图。

我已经将它转换为GeoJSON和topojson,但在任何一种情况下,尝试渲染都会导致浏览器挂起,并且该选项卡的CPU达到100%或更高。

我可以像所有US counties一样渲染更大的文件,我可以使用Mapnik或TileMill渲染文件。但是在浏览器中它会消失。

Here's the relevant code

var map = d3.select('#map').append('svg')
    .style('width', width)
    .style('height', height);

var albers = d3.geo.albersUsa();

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

d3.json(urls.drought, function(err, data) {

    var drought = window.drought = topojson.feature(data, data.objects.usdm130521);

    map.selectAll('path')
        .data(drought.features)
      .enter().append('path')
        .attr('d', path);
});

1 个答案:

答案 0 :(得分:1)

想出来了。正如USDM site says,“这些文件已投射到美国连续阿尔伯斯等面积圆锥投影。”

事实证明,这是一个问题,但我并不完全理解它。我使用EPSG: 4326将其转换为ogr2ogr

$ ogr2ogr -t_srs EPSG:4326 usdm130521-projected.shp usdm130521.shp

它呈现了。也快。

Mike Bostock写了更多关于投射topojson here的信息。

相关问题