我正在努力调整我在阅读json文件后自动调整的json文件。但我收到了错误。
$.getJSON("data/cities.json", function (data) {
getData = topojson.feature(data, data.features);
console.log( getData)
});
Cities.json看起来像
{
"type": "FeatureCollection",
"features": [{
"geometry": {
"type": "MultiPolygon",
"coordinates": [
[
[
[-73.8283219965448, 40.8446061654002],
[-73.828397789942, 40.844583182304],
[-73.8285477331865, 40.8448132168025],
[-73.8284744943625, 40.8448401137412],
[-73.8283219965448, 40.8446061654002]
]
]
]
},
"type": "Feature",
, {
"geometry": {
"type": "MultiPolygon",
"coordinates": [
[
[
[-73.832361912256, 40.8488019205992],
[-73.832369554769, 40.8487286684528],
[-73.8327312374341, 40.8487518102579],
[-73.8327304815978, 40.8487590590352],
[-73.8327235953166, 40.8488250624279],
[-73.832361912256, 40.8488019205992]
]
]
]
},
"type": "Feature"
}
}
如何使用getJSON加载json数据,然后将其传递给topojson
答案 0 :(得分:2)
GeoJSON和TopoJSON是两种不同的格式。您无法使用TopoJSON函数来处理GeoJSON。您需要将您拥有的GeoJSON转换为TopoJSON(请参阅the commandline reference),然后加载它。