D3:有一种静态放大地图的简单方法吗?

时间:2013-12-17 20:38:56

标签: d3.js geomap

我正在尝试创建我的城市地图,但默认地图太小。我不想做缩放(还),但我想将显示的尺寸加倍。

以下是脚本的摘录

var projection;
var w=1200;
var h=800;
var x=-14100;
var y=7300;
var scale=66700;

projection=d3.geo.albers()
.translate([x,y])
.scale([scale]);
var path=d3.geo.path()
.projection(projection);
var svg=d3.select("#data-div")
.append("svg")
.attr("width",w)
.attr("height",h);
var category;

// GROUPS

var paths = svg.append("g"),
 circles = svg.append("g");

// TORONTO MAP JSON

d3.json("d3_files/json/new-toronto.json",function(error, data){
paths.selectAll("path")
.data(data.features)
.enter()
.append("path")
.attr("d",path)
.attr("name",function(data){
    return"<strong>name</strong>"
}) // end name attr
.style("fill",function(data){
    return"lightgrey";
}) // end fill style
.style("stroke","#000")
}); // end toronto json

1 个答案:

答案 0 :(得分:1)

而不是:

var scale=66700;

做的:

var scale= 33350;

这将“缩放”投影。来自API

  

比例因子与两者之间的距离成线性对应   预测点