Zoom to Bounding Box with translateExtent
✓ Published0🌍 Public
Aabdul-alim
Last edited Jul 8, 2019
Created on Jul 8, 2019
Clicking a U.S. state zooms the map to that state’s bounding box, with a smooth 750-millisecond transition, while a gray mesh outlines all state boundaries. The view also resets to the full country when clicking the background. Built with D3 v4, the example uses `d3.zoom` with a `translateExtent` that constrains panning, `d3.geoPath` and `d3.geoAlbersUsa` for rendering TopoJSON state features as SVG paths, and `zoom.transform` to animate the zoom. The active state highlights in orange, and stroke widths scale inversely with the zoom level.
AI-generated descriptionBuilt with blockbuilder.org
mit Licensed