Skip to main content
100%

Basic Map Zooming

✓ Published0🌍 Public
663anp3ca
Last edited Nov 13, 2018
Created on Nov 13, 2018

This example demonstrates how d3-zoom can be used to add pan and zoom interactions to a map. The map shows the states of India, rendered as SVG paths using an azimuthal equal-area projection and TopoJSON data. Each state is filled with a distinct color from a categorical palette, and hovering highlights the state by raising it above its neighbors and applying a thicker stroke. The zoom behavior, constrained to a scale range of 1–8× and bounded by the viewport, is applied directly to the SVG element, with a transform on the group containing all map paths. The window resize handler recalculates the projection’s fit and updates the translate extent, demonstrating how d3-zoom integrates with dynamic map projections.

AI-generated description

It's ridiculous how easy d3-zoom makes it to zoom elements.

forked from <a href='http://bl.ocks.org/HarryStevens/'>HarryStevens</a>'s block: <a href='http://bl.ocks.org/HarryStevens/3bc69a5dd80b7a634b3090c54df36da9'>Basic Map Zooming</a>

gpl-3.0 Licensed

Similar vizzes