0

I am attempting to create a map of my city but the default map is too small. I don't want to do anything like zooming (yet) but I would like to double the size displayed.

Here is an extract of the script

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
PatriciaW
  • 893
  • 1
  • 12
  • 30
  • 1
    [This question](http://stackoverflow.com/questions/14492284/center-a-map-in-d3-given-a-geojson-object) should help. – Lars Kotthoff Dec 17 '13 at 21:09
  • Lars, Thank you very much, I overloked this tip when I saw Adam's comments below. I just tried it now and it works perfectly! – PatriciaW Dec 20 '13 at 14:40

1 Answers1

1

Instead of:

var scale=66700;

do:

var scale= 33350;

This will 'zoom' the projection out. From the API:

The scale factor corresponds linearly to the distance between projected points

Adam Pearce
  • 9,243
  • 2
  • 38
  • 35
  • I had tried that before I posted this question. If I change it to that value the map disappears completely. If I make smaller changes all that happens is that the map moves. – PatriciaW Dec 17 '13 at 21:56
  • You might want to post a jsfiddle or a bl.ocks – Adam Pearce Dec 17 '13 at 22:02
  • I've never used jsfiddle before ... I have created an account and posted my code but I'm not sure it is what you asked for. http://jsfiddle.net/PatriciaW/xxAJn/ – PatriciaW Dec 17 '13 at 22:27
  • Is it possible that the json file is wrong format? The header of the file starts with { "type": "FeatureCollection", "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::4269", "features": [ { "type": "Feature", "properties": { "GEO_ID": 14630026, "CREATE_ID": 63519, "NAME": "Scarborough-Rouge River (41)", "SCODE_NAME": "41", "LCODE_NAME": "EA41", "TYPE_DESC": "Ward", "TYPE_CODE": "CITW", "OBJECTID": 1, "SHAPE_AREA": 0.0, "SHAPE_LEN": 0.0 }, "geometry": { "type": "Polygon", "coordinates": .... – PatriciaW Dec 20 '13 at 04:04