Skip to content

Instantly share code, notes, and snippets.

@micahstubbs
Created August 10, 2019 23:20
Show Gist options
  • Save micahstubbs/842e41b2ac0ff702a0a04dc6e48dca92 to your computer and use it in GitHub Desktop.
Save micahstubbs/842e41b2ac0ff702a0a04dc6e48dca92 to your computer and use it in GitHub Desktop.
Simplified Globe
license: mit
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<script src="https://d3js.org/d3.v4.min.js"></script>
<script src="//unpkg.com/topojson-client@3"></script>
<script src="//unpkg.com/topojson-simplify@3"></script>
</head>
<body>
<svg width="960" height="500"></svg>
<script>
const path = d3.select('svg').append('path');
const projection = d3.geoOrthographic();
const geoPath = d3.geoPath().projection(projection);
d3.json('world-110m.json', (error, world) => {
const presimplified = topojson.presimplify(world);
const simpleWorld = topojson.simplify(presimplified, 11);
const land = topojson.feature(simpleWorld, simpleWorld.objects.land);
console.log(JSON.stringify(land))
d3.timer(t => {
projection.rotate([t * 0.05, Math.sin(t * 0.0005) * 45]);
path.attr('d', geoPath(land));
});
});
</script>
</body>
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment