Created
April 23, 2016 23:15
-
-
Save JaimeStill/8abeb0b8f6fab2be15adedf203ca1726 to your computer and use it in GitHub Desktop.
Rotating Orthographic - USA Highlighted
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> | |
<html> | |
<head> | |
<title>Rotating Orthographic - USA Highlighted</title> | |
<meta charset="utf-8" /> | |
<link href="site.css" rel="stylesheet" /> | |
</head> | |
<body> | |
<h2>Rotating Orthographic - USA Highlighted</h2> | |
<div id="rotating-orthographic"></div> | |
<script src="https://d3js.org/d3.v3.min.js" type="text/javascript"></script> | |
<script src="https://d3js.org/topojson.v1.js" type="text/javascript"></script> | |
<script src="interactivity.js"></script> | |
</body> | |
</html> |
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
(function () { | |
var createRotatingOrthographic = function () { | |
var i = 0; | |
var height = 600; | |
var width = 900; | |
var projection = d3.geo.orthographic().clipAngle(90); | |
var path = d3.geo.path().projection(projection); | |
var svg = d3.select('#rotating-orthographic') | |
.append('svg') | |
.attr({ | |
'width': width, | |
'height': height | |
}); | |
d3.json('world.json', function (data) { | |
var countries = topojson.feature(data, data.objects.countries); | |
var usa = countries.features[168]; | |
var map = svg.append('g') | |
.attr('class', 'boundary'); | |
var world = map.selectAll('path') | |
.data(countries.features); | |
var usa = map.selectAll('.usa').data([usa]); | |
world.enter() | |
.append('path') | |
.attr('d', path); | |
usa.enter() | |
.append('path') | |
.attr({ | |
'class': 'usa', | |
'd': path | |
}) | |
.style({ | |
'fill': 'dodgerblue', | |
'stroke': 'red' | |
}); | |
setInterval(function () { | |
i += 0.2; | |
projection.rotate([i, 0, 0]); | |
world.attr({ | |
'd': path | |
}); | |
usa.attr({ | |
'd': path | |
}) | |
.style({ | |
'fill': 'dodgerblue', | |
'stroke': 'red' | |
}); | |
}, 10); | |
}); | |
}; | |
createRotatingOrthographic(); | |
}()); |
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
body { | |
font-family: 'Segoe UI', sans-serif; | |
padding-left: 1em; | |
} | |
p, li { | |
max-width: 60em; | |
} | |
pre { | |
color: limegreen; | |
font-weight: bold; | |
font-family: Consolas, monospace; | |
margin: 0; | |
padding: 0; | |
display: inline-block; | |
} | |
.code-container { | |
padding: .5em; | |
background-color: #eee; | |
color: springgreen; | |
display: inline-block; | |
word-wrap: break-word; | |
} | |
.code-block { | |
display: block; | |
} | |
span.snippet{ | |
color: limegreen; | |
font-weight: bold; | |
font-family: Consolas, monospace; | |
margin: 0; | |
padding: 0; | |
} | |
.inline-element { | |
display: inline-block; | |
margin-right: 1em; | |
margin-bottom: 1em; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment