【发布时间】:2019-05-07 12:03:26
【问题描述】:
我是 Angular 的新手,我正在尝试使用 Angular/d3 构建德国地图。地图数据存储在一个Topojson文件plz_map_ger.json中:
{
"type": "Topology",
"arcs": [...],
"transform": {...},
"objects": {
"plz5stellig": {...}
}
}
这是我绘制地图的代码:
import * as d3 from "d3";
import * as t from 'topojson';
...
d3.json("../../assets/plz_map_ger.json")
.then(function(top:any) {
g.selectAll('path')
.data(t.feature(top, top.objects.plz5stellig).features)
.enter()
.append('path')
.attr('d', path)
.attr("class","kreisgrenzen")
.on("click", function() {
d3.select(this).attr("class","selected-kreis");
});
但是我得到以下编译错误:
error TS2339: Property 'features' does not exist on type 'Feature<Point, { [name: string]: any; }>'.
我需要做什么来解决这个问题?
编辑: 当我将鼠标悬停在 VS Code 中的错误上时,我收到以下消息:
Property 'features' does not exist on type 'Feature<Point, { [name: string]: any; }>'.ts(2339)
我使用以下由 mapshaper.org 创建的 Topojson 文件(这个文件有点简化,但结构保持不变): gist.github.com/.../plz_map_ger.json
【问题讨论】:
标签: angular d3.js geojson topojson