1

Code available here. Map looks like full width, but not at all. There is some indents at the top and left and right sides. All examples of d3.js maps use some strange magic numbers in scale method. I try use such numbers from this answer, but looks like it is not true for my case. So what is true way to scale map? I want to make it full width without any indents on any screen.

var body = d3.select("body").node().getBoundingClientRect();

var coef = 640 / 360;

var width = body.width;
var height = width / coef;

var svg = d3.select("body")
  .append("svg")
  .attr("width", width)
  .attr("height", height)

var projection = d3.geo.equirectangular()
  .rotate([-180, 0])
  .scale(width / 640 * 100)
  .translate([width / 2, height / 2])

var path = d3.geo.path()
  .projection(projection);


d3.json("https://dl.dropboxusercontent.com/s/20g0rtglh9xawb8/world-50m.json?dl=1", function(error, world) {
  svg.append("path")
    .datum(topojson.feature(world, world.objects.land))
    .attr("d", path);
});
Community
  • 1
  • 1
zeleniy
  • 2,232
  • 19
  • 26

0 Answers0