Skip to content

Instantly share code, notes, and snippets.

@mbostock
Last active July 22, 2018 15:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mbostock/19ffece0a45434b0eef3cc4f973d1e3d to your computer and use it in GitHub Desktop.
Save mbostock/19ffece0a45434b0eef3cc4f973d1e3d to your computer and use it in GitHub Desktop.
Fit Extent
license: gpl-3.0
height: 720
border: no
<!DOCTYPE html>
<meta charset="utf-8">
<svg width="960" height="610"></svg>
<script src="https://unpkg.com/d3@5"></script>
<script src="https://unpkg.com/topojson-client@3"></script>
<script>
var svg = d3.select("svg"),
width = +svg.attr("width"),
height = +svg.attr("height");
d3.json("https://raw.githubusercontent.com/gist/mbostock/4090846/raw/07e73f3c2d21558489604a0bc434b3a5cf41a867/us.json").then(function(us) {
var conus = topojson.feature(us, {
type: "GeometryCollection",
geometries: us.objects.states.geometries.filter(function(d) {
return d.id !== 2 // AK
&& d.id !== 15 // HI
&& d.id < 60; // outlying areas
})
});
// ESRI:102004
var path = d3.geoPath()
.projection(d3.geoConicConformal()
.parallels([33, 45])
.rotate([96, 0])
.center([0, -39])
.fitSize([width, height], conus));
svg.append("path")
.datum(conus)
.attr("d", path);
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment