Skip to content

Instantly share code, notes, and snippets.

@asuozzo
Last active July 15, 2019 18:07
Show Gist options
  • Save asuozzo/803e3943c5360214d81ec76bb847fe65 to your computer and use it in GitHub Desktop.
Save asuozzo/803e3943c5360214d81ec76bb847fe65 to your computer and use it in GitHub Desktop.
vermont
license: mit
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<script src="https://d3js.org/d3.v5.min.js"></script>
<script src="https://d3js.org/topojson.v2.min.js"></script>
<style>
body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; }
svg {width:500px;height:400px;border: 1px solid black;}
</style>
</head>
<body>
<svg></svg>
<script>
var svg = d3.select("svg"),
margin = {right: 50, left: 50},
width = parseInt(svg.style("width")) - margin.left - margin.right,
height = parseInt(svg.style("height"));
d3.json("vt.json", function(error, vt) {
if (error) throw error;
var extent = topojson.feature(vt, {
type: "GeometryCollection",
geometries: vt.objects.vt.geometries
});
var path = d3.geoPath()
.projection(d3.geoTransverseMercator()
.rotate([72 + 30 / 60, -42 - 30 / 60])
.fitSize([width, height], extent)
);
svg.append("g")
.attr("class", "states")
.selectAll("path")
.data(topojson.feature(vt, vt.objects.vt).features)
.enter().append("path")
.attr("d", path);
});
</script>
</body>
Display the source blob
Display the rendered blob
Raw
Loading
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