-
-
Save Andrew-Reid/bbfcf7d013020e9c1f19eac58e2beef4 to your computer and use it in GitHub Desktop.
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> | |
<svg width="960" height="600" fill="none" stroke="#000" stroke-linejoin="round" stroke-linecap="round"></svg> | |
<script src="https://d3js.org/d3.v4.min.js"></script> | |
<script src="https://unpkg.com/topojson-client@3"></script> | |
<script> | |
var svg = d3.select("svg"); | |
var path = d3.geoPath(); | |
d3.json("projected.topojson", function(projected) { | |
d3.json("unprojected.topojson", function(unprojected) { | |
svg.append("path") | |
.attr("d", path(topojson.feature(projected, projected.objects.nation))); | |
var projection = d3.geoAlbersUsa(); | |
var scale = projection.scale() * 6 / 5; | |
projection.scale(scale).translate([960/2,600/2]) | |
var projectedPath = d3.geoPath().projection(projection); | |
svg.append("path") | |
.attr("d", projectedPath(topojson.feature(unprojected, unprojected.objects.nation))); | |
}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment