Questions tagged «topojson»

11
给定geoJSON对象,使地图在d3中居中
当前在d3中,如果您要绘制一个geoJSON对象,则必须对其进行缩放并转换以使其达到所需的大小,然后对其进行转换以使其居中。这是一个非常繁琐的反复试验,我想知道是否有人知道更好的方法来获得这些价值? 所以例如如果我有这段代码 var path, vis, xy; xy = d3.geo.mercator().scale(8500).translate([0, -1200]); path = d3.geo.path().projection(xy); vis = d3.select("#vis").append("svg:svg").attr("width", 960).attr("height", 600); d3.json("../../data/ireland2.geojson", function(json) { return vis.append("svg:g") .attr("class", "tracts") .selectAll("path") .data(json.features).enter() .append("svg:path") .attr("d", path) .attr("fill", "#85C3C0") .attr("stroke", "#222"); }); 我该如何一点一点地获得.scale(8500)和.translate([0,-1200])?
140 d3.js  geojson  topojson 

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.