Skip to content

Instantly share code, notes, and snippets.

@Andrew-Reid
Created April 10, 2018 18:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Andrew-Reid/bbfcf7d013020e9c1f19eac58e2beef4 to your computer and use it in GitHub Desktop.
Save Andrew-Reid/bbfcf7d013020e9c1f19eac58e2beef4 to your computer and use it in GitHub Desktop.
<!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>
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
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