block by fogonwater 686102511117b84cfbed

glitch map

Full Screen

Glitchy D3.js map of the world. This combination of clipAngle with geo.mercator() sends things particularly crazy.

index.html

<!DOCTYPE html>
<meta charset="utf-8">
<style>
body {
  background: #fcfcfa;
}

.graticule {
  fill: none;
  stroke: #777;
  stroke-width: .5px;
  stroke-opacity: .5;
}

.land {
  fill: #222;
}

.boundary {
  fill: none;
  stroke: #fcfcfa;
  stroke-width: .3px;
}
</style>
<div id="chart"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.6/d3.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/topojson/1.6.19/topojson.min.js"></script>

<script>

var width = 960,
    height = 500,
    map_center = [0, 90];

var projection = d3.geo.mercator()
    .clipAngle(180 - 1e-3)
    .scale(150)
    .translate([width / 2, height / 2])
    .rotate(map_center)
    .precision(.1);

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

var graticule = d3.geo.graticule()
    .step([0, 10]);;

var svg = d3.select("#chart").append("svg")
    .attr("width", width)
    .attr("height", height);

d3.json("world-50m.json", function(error, world) {
  svg.append("path", ".graticule")
    .datum(topojson.feature(world, world.objects.land))
    .attr("class", "land")
    .attr("d", path);

  svg.append("path", ".graticule")
    .datum(topojson.mesh(
        world, world.objects.countries, function(a, b) { return a !== b; }
    ))
    .attr("class", "boundary")
    .attr("d", path);

  svg.append("path")
    .datum(graticule)
    .attr("class", "graticule")
    .attr("d", path);
});

</script>