Skip to content

Instantly share code, notes, and snippets.

Forked from nkelner/
Last active November 12, 2020 02:09
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save wboykinm/c450c20af3519a07c8ea405acd2a3292 to your computer and use it in GitHub Desktop.
A simple vector map of Vermont's Counties.
<!DOCTYPE html>
<meta charset="utf-8">
.county-boundary {
fill: none;
stroke: #333;
stroke-width: 2px;
stroke-linejoin: round;
.state-boundary {
fill: none;
stroke: #333;
stroke-linejoin: round;
text {
font-family: helvetica;
fill: black;
font-weight: 300;
text-anchor: middle;
<script src=""></script>
<script src=""></script>
var width = 960,
height = 700;
var svg ="body").append("svg")
.attr("width", width)
.attr("height", height);
var projection = d3.geo.mercator()
var path = d3.geo.path()
d3.json("vt-counties.json", function(error, vt) {
var vermont = topojson.feature(vt, vt.objects.counties);
.translate([0, 0]);
var b = path.bounds(vermont),
s = .95 / Math.max((b[1][0] - b[0][0]) / width, (b[1][1] - b[0][1]) / height),
t = [(width - s * (b[1][0] + b[0][0])) / 2, (height - s * (b[1][1] + b[0][1])) / 2];
.data(topojson.feature(vt, vt.objects.counties).features)
.attr("class", function(d) {return "county " +;})
.attr("d", path)
.style("fill", "white")
.datum(topojson.feature(vt, vt.objects.counties, function(a, b){return a !== b; }))
.attr("d", path)
.attr("class", "county-boundary");
});"height", height + "px");
Display the source blob
Display the rendered blob
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