Skip to content

Instantly share code, notes, and snippets.

@chelm
Last active December 11, 2015 03:48
Show Gist options
  • Save chelm/4540704 to your computer and use it in GitHub Desktop.
Save chelm/4540704 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<script src="http://d3js.org/d3.v3.min.js"></script>
<style type="text/css">
body{
background:white;
}
svg {
width: 960px;
height: 500px;
background: #4a8dcb;
}
</style>
</head>
<body>
<script type="text/javascript">
var svg = d3.select("body")
.append("svg")
.call(d3.behavior.zoom()
.on("zoom", redraw))
.append("g");
svg.append("g").attr("id", "countries");
var path = d3.geo.path();
// get countries and add to the map
d3.json("https://raw.github.com/chelm/jsgeo/master/world-countries.json", function(collection) {
projection = d3.geo.azimuthal()
.scale(380)
.origin([-71.03,42.37])
.mode("orthographic")
.translate([640, 400]);
g.selectAll("path")
.data(collection.features)
.enter().append("svg:path")
.style('fill-opacity', 1)
.attr('class', 'country')
.attr("d", path.projection( projection ))
function redraw() {
svg.attr("transform", "translate(" + d3.event.translate + ")scale(" + d3.event.scale + ")");
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment