0

我通过以下方式预测国家边界:

d3.json("./admin_0.topo.json", function(error, json) { 
    var L0 =  json.objects.admin_0;
//inland borders lines
    svg.append("g").attr("id","border")
        .attr("style", mesh)
    .selectAll("path")
        .data([topojson.mesh(json, L0, function(a, b) { return a !== b; })])
    .enter().append("path")
        .attr("d", path);

  //coast lines
    svg.append("g").attr("id","coast")
            .attr("style", coast)
        .append("path")
        .datum(topojson.mesh(json, L0, function(a, b) { return a == b; }))
        .attr("d", path);
});

一些边界svg线无缘无故地连接到其他边界:

在此处输入图像描述

放大时:

在此处输入图像描述

注意:海岸线和封闭的多边形都不会被弄乱。npm topojson我通过& natural earth shapefiles生成了这些数据。在黄色印度(巴基斯坦、尼泊尔、柬埔寨边界)周围似乎也缺少二分之一的国际边界。

# Download (not tested)
curl https://github.com/nvkelso/natural-earth-vector/raw/master/10m_cultural/ne_10m_admin_0_countries.shp
# shp2topojson:
topojson \
    --id-property name \
    -p name=name \
    -q 1e4 \
    --filter=small \
    -o admin_0.topo.json \
    -- admin_0=ne_10m_admin_0_countries.shp

什么是窃听?我该如何解决?

Demo , #Mesh , 可能与:D3js SVG open lines display a fill artifact, 如何修复它?& “中风破折号数组:x,y;” 搞乱svg路径?(铬)

4

1 回答 1

1

错误实际上是由于 `style="stroke-dasharray:4,4;" 在 Chrome 浏览器上。“中风破折号数组:x,y;” 搞乱svg路径?(铬)

于 2015-01-30T18:01:57.043 回答