Drilldown: states into counties

Click a state, or focus the map and press Enter on one: the keyboard drills wherever a click would. The counties pack loads on demand, the child level is restricted to the state that was clicked, and the camera frames that state before the swap so the two views line up. Which counties belong to California is not configured: TIGER counties carry state_abbr, and that is detected. Escape or the trail goes back up, and going back never refetches. Data for the level being entered is filled in from the drilldown event, which is the pattern for per-level fetching.

One option

The child level is scoped by a property holding the parent's key (TIGER state_abbr, Eurostat cntr_code, Natural Earth adm0_a3) or by a hierarchical key prefix (county FIPS 06037 under state 06, NUTS DE12 under DE1). Property detection runs first because it is exact. When neither route matches anything, the drilldown is declined with a reason rather than performed onto an empty map.

series: [{
  name: 'Adoption',
  joinBy: { data: 'key' },
  data: rows,
  drilldown: { map: 'us/counties' },
}]

map.on('drilldown', ({ key, name, depth, featureCount }) => { /* fetch this level */ })
map.drillTo('CA')       // as a click would
map.drillUp(Infinity)   // back to the top; never refetches