Fork of Svelte + D3: Map (with visible hidden canvas) on canvas with zoom on click
✓ Published0🌍 Public
Bbaltasar.ms@gmail.com
Last edited Apr 14, 2024
Created on Apr 12, 2024
This interactive map of US counties allows users to click on a county to zoom into it, with an animated transition, and press Escape to zoom back out. The visualization uses a dual-canvas approach: one visible canvas renders the map in steel blue, while a second hidden canvas uses color-coded pick IDs for hit detection, with mouse position read via Canvas `getImageData` to identify hovered counties. The map is drawn using `d3.geoPath` with a `geoAlbersUsa` projection from GeoJSON county boundaries, while the zoom animation is powered by Svelte’s `tweened` motion primitive from `svelte/motion`.
AI-generated descriptionMIT Licensed