【问题标题】:Topojson missing outside boundariesTopojson 缺少外部边界
【发布时间】:2015-09-30 18:00:58
【问题描述】:

在渲染我的 topojson 时,我错过了状态的外部边界。

例如,我对南方的看法是这样的:

相反,我需要填充所有外部边界。

我的地图风格如下:

.state-boundary {
        stroke: #00001d;
        stroke-width: .5px;
        fill: white;
        stroke-linejoin: round;
        stroke-linecap: round;
      }

geojson 在转换为 topojson 之前如下所示:

我的d3如下:

svg.append("path")
        .datum(topojson.mesh(topology, topology.objects.south, function(a, b) { return a !== b; }))
        .attr("d", path)
        .attr("class", "state-boundary");

【问题讨论】:

  • 如何渲染你的 topojson?你用的是什么库?
  • 浏览器中的 D3。我使用 topojson 命令行工具制作了 Topojson 文件。
  • 您不能在此使用网格。当您只想拥有内部边界时使用网格。对于所有你需要使用topojson.feature

标签: d3.js topojson


【解决方案1】:

所以,这只是改变网格方法的问题。我真的不明白其中的区别,所以也许有人可以插话:

svg.append("path")
        .datum(topojson.mesh(topology, topology.objects.south))
        .attr("d", path)
        .attr("class", "state-boundary");

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-18
    • 2016-05-01
    • 1970-01-01
    • 2018-11-07
    • 2020-05-16
    • 2019-03-07
    相关资源
    最近更新 更多