编辑:在 jsfiddle https://jsfiddle.net/exLtcgrq/1/上重新创建逻辑
我正在尝试使用 D3 V4 API 将一个简单的 GeoJSON 文件解析为 D3。
我的 GeoJSON 很简单:
{ "type": "FeatureCollection",
"features": [
{ "type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[10.0, 10.0], [60.0, 40.0], [50.0, 75.0],[20.0, 60.0]
]
},
"properties": {
"id": "1",
"Type": "campingspot"
}
},
{ "type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[20.0, 65.0], [50.0, 80.0], [50.0, 110.0],[20.0, 115.0]
]
},
"properties": {
"id": "1",
"Type": "campingspot"
}
}
]
}
Run Code Online (Sandbox Code Playgroud)
我因此使用 d3.json() 方法加载并尝试使用 d3-geo api 将其转换为具有以下代码的路径: …