Skip to main content
100%

click-to-center via transform

✓ Published0🌍 Public
Mmbostock
Last edited Feb 9, 2016
Created on Mar 26, 2012

Clicking a U.S. state smoothly shifts the entire map to center that state, using a transform transition on a group element. The map renders TopoJSON state boundaries via `d3.geo.albersUsa` and `d3.geo.path`, while a click handler computes each state's centroid with `path.centroid` and animates the group's `translate` attribute over 750 milliseconds. Clicking the background or the already-centered state re-centers the view.

AI-generated description
gpl-3.0 Licensed

Similar vizzes