index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Greenland</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.6/d3.min.js"></script>
</head>
<body>
<style>
body {
margin: 0;
}
.sphere {
fill: #A7DBD8;
stroke: #79A09E;
}
.land {
fill: #E0E4CC;
stroke: #ACAF9F;
stroke-width: 1;
}
.graticule {
fill: none;
stroke: #79A09E;
stroke-width: 1;
stroke-dasharray: 1,2;
}
.overlay {
fill-opacity: 0;
}
#map-container svg {
float: left;
}
</style>
<div id="map-container"></div>
<script>
var width = 960,
height = 480;
var div = d3.select('#map-container'),
svg = div.selectAll('svg').data([0]);
svg.enter().append('svg');
svg.attr('width', height).attr('height', height);
svg.exit().remove();
var projection = d3.geo.mercator()
.scale(height / (2 * Math.PI))
.translate([height / 2, height / 2]);
var pathGenerator = d3.geo.path()
.projection(projection);
var graticule = d3.geo.graticule();
d3.json('greenland.geojson', function(err, data) {
if (err) { throw err; }
var grp = svg.selectAll('g.container').data([data, data]);
grp.enter().append('g').classed('container', true);
grp.exit().remove();
var sphere = grp.selectAll('path.sphere').data([{type: 'Sphere'}]);
sphere.enter().append('path').classed('sphere', true);
sphere.attr('d', pathGenerator);
sphere.exit().remove();
var lines = grp.selectAll('path.graticule').data([graticule()]);
lines.enter().append('path').classed('graticule', true);
lines.attr('d', pathGenerator);
lines.exit().remove();
var land = grp.selectAll('path.land').data([data]);
land.enter().append('path').classed('land', true);
land.attr('d', pathGenerator);
land.exit().remove();
});
</script>
</body>
</html>