Skip to main content
100%

Project to Bounding Box

✓ Published0🌍 Public
Mmbostock
Last edited Feb 9, 2016
Created on Feb 4, 2013

This example shows a single state selected from a GeoJSON collection and highlights it with an outline, while displaying the full set of U.S. state boundaries in gray. It centers the highlighted state within the viewport by using the Albers projection’s `d3.geo.albers()` and adjusting its scale and translation based on the bounding box computed via `path.bounds()`. The code loads TopoJSON data, converts it to GeoJSON with `topojson.feature`, and renders both the state mesh and outline as SVG paths using `d3.geo.path()`.

AI-generated description

In response to a Stack Overflow question regarding centering a map given a GeoJSON object.

gpl-3.0 Licensed

Similar vizzes