// Generated by CoffeeScript 1.10.0 (function() { var contents, graticule, height, path, projection, svg, width, zoom, zoomable_layer; svg = d3.select('svg'); width = svg.node().getBoundingClientRect().width; height = svg.node().getBoundingClientRect().height; zoomable_layer = svg.append('g'); zoom = d3.zoom().scaleExtent([-Infinity, Infinity]).on('zoom', function() { zoomable_layer.attrs({ transform: d3.event.transform }); return zoomable_layer.selectAll('.label > text').attrs({ transform: "scale(" + (1 / d3.event.transform.k) + ")" }); }); svg.call(zoom); projection = d3.geoWinkel3().rotate([0, 0]).center([0, 0]).scale((width - 3) / (2 * Math.PI)).translate([width / 2, height / 2]); path = d3.geoPath(projection); graticule = d3.geoGraticule(); svg.append('defs').append('path').datum(graticule.outline()).attrs({ id: 'sphere', d: path }); zoomable_layer.append('use').attrs({ "class": 'sphere_fill', 'xlink:href': '#sphere' }); contents = zoomable_layer.append('g'); zoomable_layer.append('path').datum(graticule).attrs({ "class": 'graticule', d: path }); zoomable_layer.append('use').attrs({ "class": 'sphere_stroke', 'xlink:href': '#sphere' }); d3.json('https://unpkg.com/world-atlas@1/world/50m.json', function(geo_data) { return d3.tsv('https://unpkg.com/world-atlas@1/world/50m.tsv', function(data) { var countries, countries_data, en_countries, en_labels, index, labels; index = {}; data.forEach(function(d) { return index[d.iso_n3] = d; }); countries_data = topojson.feature(geo_data, geo_data.objects.countries).features; countries = contents.selectAll('.country').data(countries_data); en_countries = countries.enter().append('path').attrs({ "class": 'country', d: path }); en_countries.append('title').text(function(d) { if (d.id === '-99') { return 'invalid ISO code'; } else { return index[d.id].formal_en; } }); labels = contents.selectAll('.label').data(countries_data); en_labels = labels.enter().append('g').attrs({ "class": 'label', transform: function(d) { var ref, x, y; ref = projection(d3.geoCentroid(d)), x = ref[0], y = ref[1]; return "translate(" + x + "," + y + ")"; } }).classed('error', function(d) { return d.id === '-99'; }); return en_labels.append('text').text(function(d) { return index[d.id].iso_a2; }); }); }); }).call(this);