Skip to content

Instantly share code, notes, and snippets.

@yelper
Forked from mbostock/.block
Last active August 29, 2015 14:15
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 yelper/b6647329ef67666c8d03 to your computer and use it in GitHub Desktop.
Save yelper/b6647329ef67666c8d03 to your computer and use it in GitHub Desktop.
Unlabeled map of the US (Albers projection)

Please feel free to fork this gist (click the pound [#] link up top). You can add your own cities using the GeoJSON format, and add them in with D3.

These state and country boundaries are extracted from a single TopoJSON file. States are stroked in thin black and the country in thick black.

<!DOCTYPE html>
<meta charset="utf-8">
<style>
path {
fill: none;
stroke: #000;
stroke-width: .5px;
}
.land-boundary {
stroke-width: 1px;
}
.county-boundary {
stroke: none;
}
</style>
<body>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="http://d3js.org/topojson.v1.min.js"></script>
<script>
var width = 1920,
height = 1000;
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, topology) {
svg.append("path")
.datum(topojson.feature(topology, topology.objects.land))
.attr("d", path)
.attr("class", "land-boundary");
svg.append("path")
.datum(topojson.mesh(topology, topology.objects.counties, function(a, b) { return a !== b && (a.id / 1000 | 0) === (b.id / 1000 | 0); }))
.attr("d", path)
.attr("class", "county-boundary");
svg.append("path")
.datum(topojson.mesh(topology, topology.objects.states, function(a, b) { return a !== b; }))
.attr("d", path)
.attr("class", "state-boundary");
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment