-
-
Save mbostock/3734168 to your computer and use it in GitHub Desktop.
Rotating Orthographic
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
license: gpl-3.0 |
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> | |
<meta charset="utf-8"> | |
<style> | |
circle { | |
fill: none; | |
stroke: #000; | |
stroke-width: 2px; | |
} | |
</style> | |
<body> | |
<script src="//d3js.org/d3.v3.min.js"></script> | |
<script src="//d3js.org/topojson.v1.min.js"></script> | |
<script> | |
var width = 960, | |
height = 500, | |
radius = 240; | |
var origin = [-71, 42], | |
velocity = [.012, -.002], | |
t0 = Date.now(); | |
var projection = d3.geo.orthographic() | |
.scale(radius) | |
.clipAngle(90); | |
var path = d3.geo.path() | |
.projection(projection); | |
var svg = d3.select("body").append("svg") | |
.attr("width", width) | |
.attr("height", height); | |
svg.append("circle") | |
.attr("cx", width / 2) | |
.attr("cy", height / 2) | |
.attr("r", radius); | |
d3.json("/mbostock/raw/4090846/world-110m.json", function(error, world) { | |
if (error) throw error; | |
var feature = svg.append("path") | |
.datum(topojson.feature(world, world.objects.land)) | |
.attr("d", path); | |
d3.timer(function() { | |
var t = Date.now() - t0; | |
projection.rotate([origin[0] + velocity[0] * t, origin[1] + velocity[1] * t]); | |
feature.attr("d", path); | |
}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hello! where can i get the data:world-110m.json