Skip to content

Instantly share code, notes, and snippets.

Forked from mbostock/.block
Last active February 9, 2016 01:38
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Interactive Gnomonic
license: gpl-3.0
<!DOCTYPE html>
<meta charset="utf-8">
<script src="//"></script>
<script src="//"></script>
var width = 960,
height = 500;
var projection = d3.geo.gnomonic()
var path = d3.geo.path()
var λ = d3.scale.linear()
.domain([0, width])
.range([-180, 180]);
var φ = d3.scale.linear()
.domain([0, height])
.range([90, -90]);
var svg ="body").append("svg")
.attr("width", width)
.attr("height", height);
svg.on("mousemove", function() {
var p = d3.mouse(this);
projection.rotate([λ(p[0]), φ(p[1])]);
svg.selectAll("path").attr("d", path);
d3.json("/mbostock/raw/4090846/world-110m.json", function(error, world) {
if (error) throw error;
.attr("class", "land")
.attr("d", path);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment