Skip to content

Instantly share code, notes, and snippets.

Forked from mbostock/.block
Last active November 24, 2023 04:46
  • Star 4 You must be signed in to star a gist
  • Fork 9 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
U.S. Counties TopoJSON
license: gpl-3.0
height: 600
border: no
<!DOCTYPE html>
.counties :hover {
fill: red;
.county-borders {
fill: none;
stroke: #fff;
stroke-width: 0.5px;
stroke-linejoin: round;
stroke-linecap: round;
pointer-events: none;
<svg width="960" height="600"></svg>
<script src=""></script>
<script src=""></script>
var svg ="svg");
var path = d3.geoPath();
d3.json("", function(error, us) {
if (error) throw error;
.attr("class", "counties")
.data(topojson.feature(us, us.objects.counties).features)
.attr("d", path);
.attr("class", "county-borders")
.attr("d", path(topojson.mesh(us, us.objects.counties, function(a, b) { return a !== b; })));
Copy link

For zooming, var path = d3.geoPath(d3.geoIdentity().translate([-3300, -1100]).scale(5));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment