Created
August 8, 2017 17:43
-
-
Save milafrerichs/7f855a6f84b59d0b1df7a5f64dc52e1f to your computer and use it in GitHub Desktop.
JS Bin rotating globe // source http://jsbin.com/ruretuc
This file contains hidden or 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> | |
<html> | |
<head> | |
<meta name="description" content="rotating globe"> | |
<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="900" 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> |
This file contains hidden or 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
.grati path { | |
fill: none; | |
stroke: #79A09E; | |
stroke-width: 1; | |
stroke-dasharray: 1,2; | |
} |
This file contains hidden or 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
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