-
-
Save Andrew-Reid/b40c1f11fbc49998e67c493fd473c075 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> | |
<meta charset="utf-8"> | |
<body> | |
<script src="https://d3js.org/d3.v4.min.js"></script> | |
<script src="https://d3js.org/topojson.v2.min.js"></script> | |
<svg width="960" height="600"></svg> | |
<script> | |
var width = 960; | |
var height = 600; | |
var svg = d3.select("svg"); | |
var projection = d3.geoMercator(); | |
var path = d3.geoPath().projection(projection); | |
d3.json("topo.topojson", function(error, aisp) { | |
if (error) throw error; | |
projection.fitSize([width,height], topojson.feature(aisp, aisp.objects.convert)); | |
svg.append("g") | |
.attr("class", "states") | |
.selectAll("path") | |
.data(topojson.feature(aisp, aisp.objects.convert).features) | |
.enter().append("path") | |
.attr("d", path); | |
svg.append("path") | |
.attr("class", "state-borders") | |
.attr("d", path(topojson.mesh(aisp, aisp.objects.convert, function(a, b) { return a !== b; }))); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment