Skip to content

Instantly share code, notes, and snippets.

@mbostock
Forked from jasondavies/README.md
Last active February 9, 2016 01:35
Show Gist options
  • Save mbostock/3734168 to your computer and use it in GitHub Desktop.
Save mbostock/3734168 to your computer and use it in GitHub Desktop.
Rotating Orthographic
license: gpl-3.0
<!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>
@ZhangTianXu
Copy link

hello! where can i get the data:world-110m.json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment