Skip to content

Instantly share code, notes, and snippets.

@milafrerichs
Created August 3, 2017 13:33
Show Gist options
  • Save milafrerichs/46901ad0b08ef201ea3e67e4f50fec7f to your computer and use it in GitHub Desktop.
Save milafrerichs/46901ad0b08ef201ea3e67e4f50fec7f to your computer and use it in GitHub Desktop.
JS Bin // source http://jsbin.com/ruretuc
<!DOCTYPE html>
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/4.2.3/d3.min.js"></script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<style id="jsbin-css">
.grati path {
fill: none;
stroke: #79A09E;
stroke-width: 1;
stroke-dasharray: 1,2;
}
</style>
</head>
<body>
<div id="map">
<svg width="600" height="600">
<g class="grati"></g>
<g class="earth"></g>
</svg>
</div>
<script id="jsbin-javascript">
var projection = d3.geoOrthographic();
var yaw = 300;
var map = d3.select("#map g.earth");
var g = d3.select("#map g.grati");
var geojson;
var geoGenerator = d3.geoPath()
.projection(projection);
var graticule = d3.geoGraticule();
function update() {
projection.rotate([yaw, -45])
u = map.selectAll('path')
.data(geojson.features);
u.enter()
.append('path')
.merge(u)
.attr('d', geoGenerator);
u.exit().remove()
gr = g.selectAll('path').data([graticule()])
gr.enter()
.append('path')
.merge(gr)
.attr('d', geoGenerator);
gr.exit().remove()
yaw -= 0.2
}
// REQUEST DATA
d3.json('https://gist.githubusercontent.com/d3indepth/f28e1c3a99ea6d84986f35ac8646fac7/raw/c58cede8dab4673c91a3db702d50f7447b373d98/ne_110m_land.json', function(err, json) {
geojson = json;
window.setInterval(update, 100);
})
</script>
<script id="jsbin-source-css" type="text/css">.grati path {
fill: none;
stroke: #79A09E;
stroke-width: 1;
stroke-dasharray: 1,2;
}</script>
<script id="jsbin-source-javascript" type="text/javascript">var projection = d3.geoOrthographic();
var yaw = 300;
var map = d3.select("#map g.earth");
var g = d3.select("#map g.grati");
var geojson;
var geoGenerator = d3.geoPath()
.projection(projection);
var graticule = d3.geoGraticule();
function update() {
projection.rotate([yaw, -45])
u = map.selectAll('path')
.data(geojson.features);
u.enter()
.append('path')
.merge(u)
.attr('d', geoGenerator);
u.exit().remove()
gr = g.selectAll('path').data([graticule()])
gr.enter()
.append('path')
.merge(gr)
.attr('d', geoGenerator);
gr.exit().remove()
yaw -= 0.2
}
// REQUEST DATA
d3.json('https://gist.githubusercontent.com/d3indepth/f28e1c3a99ea6d84986f35ac8646fac7/raw/c58cede8dab4673c91a3db702d50f7447b373d98/ne_110m_land.json', function(err, json) {
geojson = json;
window.setInterval(update, 100);
})</script></body>
</html>
.grati path {
fill: none;
stroke: #79A09E;
stroke-width: 1;
stroke-dasharray: 1,2;
}
var projection = d3.geoOrthographic();
var yaw = 300;
var map = d3.select("#map g.earth");
var g = d3.select("#map g.grati");
var geojson;
var geoGenerator = d3.geoPath()
.projection(projection);
var graticule = d3.geoGraticule();
function update() {
projection.rotate([yaw, -45])
u = map.selectAll('path')
.data(geojson.features);
u.enter()
.append('path')
.merge(u)
.attr('d', geoGenerator);
u.exit().remove()
gr = g.selectAll('path').data([graticule()])
gr.enter()
.append('path')
.merge(gr)
.attr('d', geoGenerator);
gr.exit().remove()
yaw -= 0.2
}
// REQUEST DATA
d3.json('https://gist.githubusercontent.com/d3indepth/f28e1c3a99ea6d84986f35ac8646fac7/raw/c58cede8dab4673c91a3db702d50f7447b373d98/ne_110m_land.json', function(err, json) {
geojson = json;
window.setInterval(update, 100);
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment