transitlos.map.scope_panel¶
Scope selector of the stats panels: which data every tab shows (nation / state / county / place) and what it is compared with (none / nation / state / county / place), plus the Original / With-edits scenario.
Injected into a MapLibre map.html that already has the stats panel (build._inject_maplibre_stats_panel_into_saved_html).
Data comes from stats_chunks/ (written by the study, e.g. usa_study/code/stats_chunks.py):
* index.json: {"states": [{key, name, bbox, rings, counties: [{id, name}], places: [{id, name}], n}]};
* <key>.json.gz: column-oriented cells of one state (h3_cell, level_of_service, ..., county, place = index or -1).
The nation is window.__statsData.metro (the coarse grid embedded in the page).
Rules (user spec): Nation switches everything else off; State needs a state picked (clicking it again deactivates it);
County and Place are mutually exclusive and only offered after a state is picked, choosing from that state's list (type to
filter). Zooming out until the view covers several states resets to the nation and no comparison; zooming into a single state
selects that state automatically.
address_js(zoom, form='addressSearch', inp='addressInput', msg='addressMsg', country='us')
¶
The address search script (suggestions as you type via Photon, OSM Nominatim on Go, marker cleared with the box).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
zoom
|
Zoom after a search. |
required | |
form
|
Form element id. |
'addressSearch'
|
|
inp
|
Input element id. |
'addressInput'
|
|
msg
|
Message element id. |
'addressMsg'
|
|
country
|
Country code that biases the search. |
'us'
|
replace_scope_js_in_saved_html(path, cfg)
¶
Development helper: swap the scope + address scripts of an already built page for the current ones (no rebuild).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Built page. |
required |
cfg
|
dict
|
Scope configuration. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the page has no scope script. |
inject_scope_into_saved_html(path, cfg)
¶
Replace the Metro/City-core buttons and per-tab compare logic of the saved page's stats panel with the scope bar.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Built page. |
required |
cfg
|
dict
|
Scope configuration. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The path. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the page has no stats panel. |