RBush+canvas+svg
A choropleth map of Spanish municipalities colors each region by population variation, using a canvas basemap for the filled polygons and an SVG overlay for a hover outline. The code builds an R-tree spatial index with `rbush` to quickly identify the municipality under the cursor, then renders a highlighted `d3.geoPath` in SVG. It uses `d3-geo` with the `geoConicConformalSpain` projection and `topojson-client` to load boundaries, with tooltip data from a companion JSON file.
AI-generated descriptionThis canvas map use rbush to create a R-tree-based 2D spatial index for a best hover effect performance.
The idea is to create a canvas basemap where a svg path appears to create the hover effect.
Spain has more than 8120 municipalities (features) so it's a great scenario to test this idea. Thanks to rbush its not necessary to iterate along the whole feature set to extract the feature where user is hovering.
Inspiration implementation comes from spamjs. Data from ElConfidencial.com