Skip to content

Instantly share code, notes, and snippets.

@bradoyler
Last active August 15, 2016 03:32
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 bradoyler/12e9a1eb44d6ead3cc6834bab9823e71 to your computer and use it in GitHub Desktop.
Save bradoyler/12e9a1eb44d6ead3cc6834bab9823e71 to your computer and use it in GitHub Desktop.
US Map example
license: gpl-3.0
<!DOCTYPE html>
<meta charset="utf-8">
<style>
.mesh {
fill: #fff;
stroke: #333;
stroke-width: 1px;
stroke-linejoin: round;
}
</style>
<body>
<script src="//d3js.org/d3.v3.min.js"></script>
<script src="//d3js.org/topojson.v1.min.js"></script>
<script>
var width = 960, height = 500;
var path = d3.geo.path();
var svg = d3.select("body").append("svg")
.attr("width", width).attr("height", height);
d3.json("/mbostock/raw/4090846/us.json", function(error, us) {
if (error) throw error;
svg.append("path")
.datum(topojson.feature(us, us.objects.land))
.attr("class", "mesh")
.attr("d", path);
svg.append("path")
.datum(topojson.mesh(topology, topology.objects.states, function(a, b) { return a !== b; }))
.attr("class", "mesh")
.attr("d", path);
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment