我正在合并代码,依赖于v0的代码在v1上会出错。
topojson.v0.min.js和topojson.v1.min.js之间的语法变化有哪些?*
--
可疑语法列表:
- V0 > V1
- .object > .feature
- .geometries > .features(在某些情况下或总是?)
- *.coordinates > *.geometry.coordinates
- 其他?
我正在合并代码,依赖于v0的代码在v1上会出错。
topojson.v0.min.js和topojson.v1.min.js之间的语法变化有哪些?*
--
可疑语法列表:
svg.selectAll("path")
.data(topojson.object(topology, topology.objects.states).geometries)
.enter().append("path")
.attr("d", path);
svg.selectAll("path")
.data(topojson.feature(topology, topology.objects.states).features)
.enter().append("path")
.attr("d", path);
topojson.object(topology, topology.objects.points).geometries.forEach(function(point) {
console.log("x, y", point.coordinates[0], point.coordinates[1]);
});
在1.0及以后版本,相应的代码为:
topojson.feature(topology, topology.objects.points).features.forEach(function(point) {
console.log("x, y", point.geometry.coordinates[0], point.geometry.coordinates[1]);
});