Last active
December 27, 2015 12:48
-
-
Save wknowles/60aa6f0e2cab80473b9a to your computer and use it in GitHub Desktop.
lagrange
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<link rel="shortcut icon" href="/icon/favicon.ico" type="image/x-icon"> | |
<link rel="icon" href="/icon/favicon.png" type="image/png"> | |
<link rel="icon" sizes="32x32" href="/icon/favicon-32.png" type="image/png"> | |
<link rel="icon" sizes="64x64" href="/icon/favicon-64.png" type="image/png"> | |
<link rel="icon" sizes="96x96" href="/icon/favicon-96.png" type="image/png"> | |
<link rel="icon" sizes="196x196" href="/icon/favicon-196.png" type="image/png"> | |
<link rel="apple-touch-icon" sizes="152x152" href="/icon/apple-touch-icon.png"> | |
<link rel="apple-touch-icon" sizes="60x60" href="/icon/apple-touch-icon-60x60.png"> | |
<link rel="apple-touch-icon" sizes="76x76" href="/icon/apple-touch-icon-76x76.png"> | |
<link rel="apple-touch-icon" sizes="114x114" href="/icon/apple-touch-icon-114x114.png"> | |
<link rel="apple-touch-icon" sizes="120x120" href="/icon/apple-touch-icon-120x120.png"> | |
<link rel="apple-touch-icon" sizes="144x144" href="/icon/apple-touch-icon-144x144.png"> | |
<meta name="msapplication-TileImage" content="/icon/favicon-144.png"> | |
<meta name="msapplication-TileColor" content="#FFFFFF"> | |
<style> | |
body { | |
background: #fcfcfa; | |
} | |
.stroke { | |
fill: none; | |
stroke: #000; | |
stroke-width: 3px; | |
} | |
.fill { | |
fill: #fff; | |
} | |
.graticule { | |
fill: none; | |
stroke: #777; | |
stroke-width: .5px; | |
stroke-opacity: .5; | |
} | |
.land { | |
fill: #222; | |
} | |
.boundary { | |
fill: none; | |
stroke: #fff; | |
stroke-width: .5px; | |
} | |
</style> | |
</head> | |
<body> | |
<script src="//d3js.org/d3.v3.min.js"></script> | |
<script src="//d3js.org/d3.geo.projection.v0.min.js"></script> | |
<script src="//d3js.org/topojson.v1.min.js"></script> | |
<script> | |
var width = 680, | |
height = 680; | |
var projection = d3.geo.lagrange() | |
.scale(168) | |
.translate([width / 2, height / 2]) | |
.precision(.1); | |
var path = d3.geo.path() | |
.projection(projection); | |
var graticule = d3.geo.graticule(); | |
var svg = d3.select("body").append("svg") | |
.attr("width", width) | |
.attr("height", height); | |
svg.append("defs").append("path") | |
.datum({type: "Sphere"}) | |
.attr("id", "sphere") | |
.attr("d", path); | |
svg.append("use") | |
.attr("class", "stroke") | |
.attr("xlink:href", "#sphere"); | |
svg.append("use") | |
.attr("class", "fill") | |
.attr("xlink:href", "#sphere"); | |
svg.append("path") | |
.datum(graticule) | |
.attr("class", "graticule") | |
.attr("d", path); | |
d3.json("world-50m.json", function(error, world) { | |
if (error) throw error; | |
svg.insert("path", ".graticule") | |
.datum(topojson.feature(world, world.objects.land)) | |
.attr("class", "land") | |
.attr("d", path); | |
svg.insert("path", ".graticule") | |
.datum(topojson.mesh(world, world.objects.countries, function(a, b) { return a !== b; })) | |
.attr("class", "boundary") | |
.attr("d", path); | |
}); | |
d3.select(self.frameElement).style("height", height + "px"); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment