ワンクリックで
learn-map-layers
Layer stack, sources, map types (district vs COI), style expressions, shatter filters
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Layer stack, sources, map types (district vs COI), style expressions, shatter filters
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
SQLAlchemy-first DB patterns, Alembic migrations, ParentChildEdges partition handling, and UDF policy
FastAPI + SQLModel conventions, request dependencies, transaction safety, and backend architecture
Next.js best practices - RSC boundaries, data patterns, async APIs, error handling, route handlers, directives, runtime selection
Upgrade Next.js to the latest version following official migration guides and codemods
Auth0 scopes, recaptcha verification, and share/edit token security patterns
CMS editing/review workflows, TipTap extensions, and comment moderation
| name | learn-map-layers |
| description | Layer stack, sources, map types (district vs COI), style expressions, shatter filters |
| user-invocable | false |
Map layer rendering architecture: layer stack, source configuration, map type rendering differences (district vs community/COI), style expressions, shatter filters, overlays, and basemap composition.
The app supports three map types (DistrictrMap.map_type): "default", "local", and "community".
| Aspect | District (default/local) | Community (community) |
|---|---|---|
| Route | /map/edit/[map_id] | /coi/edit/[document_id] |
| Page component | MapPage -> MainMap | CoiMapPage -> CoiMap |
| Layer component | BlockLayers -> ZoneLayerGroup | CoiBlockLayers -> CoiAssignmentLayers |
| Assignment store | assignmentsStore | coiAssignmentsStore |
| Default basemap | MINIMAL | STREETS |
| Zone numbers | Shown | Hidden |
| Feature-state key | zone (1-indexed integer) | community + per-community flags (community_1, community_2, ...) |
| Color source | Color scheme array -> zone index | Per-community color from community.color |
| Visibility control | Global showPaintedDistricts | Per-community communityVisibility map |
| Render ordering | Single layer per scope | One layer per community, selected community on top |
Map mode ('districts' | 'coi') is set via useInitializeMapMode hook, which applies mode-specific defaults from mapModeDefaults.ts before document loading begins.
app/src/app/constants/map/layerIds.ts - canonical layer ID constants (BLOCK, ZONE_LABELS, OVERLAY, COUNTIES)app/src/app/constants/map/layerRenderConfig.ts - anchor layer order and default beforeId mappingsapp/src/app/constants/map/layerStyle.ts - ZONE_ASSIGNMENT_STYLE, COMMUNITY_ASSIGNMENT_STYLE, getLayerFill, basemap IDs, opacity constantsapp/src/app/constants/map/overlayLayerStyles.ts - overlay-specific stylingapp/src/app/components/Map/GeoSources/BlockSource.tsx - PMTiles vector source (blocks), registers pmtiles:// protocolapp/src/app/components/Map/GeoSources/PointSource.tsx - selection point sources (parent + child)app/src/app/components/Map/PolygonLayers/BlockLayers.tsx - orchestrates parent/child ZoneLayerGroup instancesapp/src/app/components/Map/PolygonLayers/ZoneLayers/ZoneLayerGroup.tsx - composes assignment + highlight + hover layersapp/src/app/components/Map/PolygonLayers/ZoneLayers/ZoneAssignmentLayer.tsx - fill layer with zone color expressionapp/src/app/components/Map/PolygonLayers/ZoneLayers/ZoneHighlightLayer.tsx - outline layer for focus/highlight/broken statesapp/src/app/components/Map/PolygonLayers/CoiBlockLayers.tsx - orchestrates per-community layers with visibility + render orderapp/src/app/components/Map/PolygonLayers/CoiAssignmentLayers.tsx - creates one layer per community, manages selected-on-top orderingapp/src/app/components/Map/PolygonLayers/CoiAssignmentLayer.tsx - individual community fill layerapp/src/app/components/Map/MainMap.tsx - district map shell (uses BlockLayers)app/src/app/components/Map/CoiMap.tsx - community map shell (uses CoiBlockLayers)app/src/app/components/Map/MapContainer.tsx - shared map shell (events, basemap, locking, cursor)app/src/app/components/Map/MapLayerAnchors.tsx - creates invisible anchor layers that define render orderapp/src/app/components/Map/PolygonLayers/CountyLayers.tsx - county boundary + label layersapp/src/app/components/Map/PolygonLayers/OverlayLayers.tsx - user-provided overlay layersapp/src/app/hooks/useLayerFilter.ts - shatter-aware layer filter expressionsapp/src/app/hooks/useInitializeMapMode.ts - mode initialization hookapp/src/app/constants/map/mapModeDefaults.ts - per-mode default optionsapp/src/app/constants/map/mapDefaults.ts - numeric limits (districts, communities)app/src/app/utils/map/mapRenderSubs.ts - render subscriber that applies feature-state to layersLayers are ordered via invisible anchor layers created by MapLayerAnchors. From top to bottom:
anchor-hover <- Hover/tooltip layers
anchor-overlays <- User overlay layers
anchor-demography <- Demographic choropleth
anchor-assignments <- Zone/community fill + highlight layers
anchor-geometry-outline <- Geometry outlines
anchor-counties <- County boundaries + labels
[basemap layers] <- Basemap (MINIMAL, STREETS, SATELLITE)
Block layers (both parent and child scopes) position themselves relative to these anchors via DEFAULT_BLOCK_LAYER_ORDER:
anchor-assignmentsanchor-assignmentsanchor-demographyanchor-hoveranchor-geometry-outlineAll map geometries come from a single PMTiles vector source:
'blocks' (constant: CANONICAL_LAYER_IDS.SOURCES.BLOCK)pmtiles://{TILESET_URL}/{mapDocument.tiles_s3_path}promoteId="path" - the path property becomes the feature ID for setFeatureStatemapDocument.parent_layer - parent geography (e.g., VTDs, precincts)mapDocument.child_layer - child geography for shatter (e.g., census blocks), nullableZONE_ASSIGNMENT_STYLE(colorScheme) builds a case expression:
['case',
['==', ['feature-state', 'zone'], 1], colorScheme[0],
['==', ['feature-state', 'zone'], 2], colorScheme[1],
...
'#cecece'] // fallback for unassigned
Each community gets its own layer with a single fill color. Membership is determined by the feature-state flag community_{id}. The COMMUNITY_ASSIGNMENT_STYLE builds a similar case expression but is used for the shared rendering path.
getLayerFill(captiveIds?, isDemographic?) builds a case expression controlling opacity:
broken: true -> 0 (hidden shattered parent)ZoneHighlightLayer uses feature-state to control outline color and width:
focused: true -> black, 3.5pxhighlighted: true -> yellow (#e5ff00), 3.5pxParent and child scopes share the same vector source but use different source-layers and filters:
['!', ['match', ['get', 'path'], [...parentIds], true, false]]['match', ['get', 'path'], [...childIds], true, false]When a parent is shattered:
broken: true (hides via opacity expression)Filter construction lives in useLayerFilter(child: boolean).
Three basemap options defined in BASEMAP_IDS:
MINIMAL - default for district modeSTREETS - default for community modeSATELLITE - available in both modesBasemap switching is handled in MapContainer via the map style URL.
Overlay layers are positioned at anchor-overlays and support both PMTiles and GeoJSON sources. Overlay constraints can restrict painting (managed by overlayStore). Layer IDs use the OVERLAY prefix constants.
layerRenderConfig.ts). Never use hardcoded beforeId values that bypass the anchor system.blocks source ID and promoteId="path" are load-bearing contracts - feature-state, filters, and event queries all depend on them.shatterIds in the assignment store. A mismatch causes ghost features or missing geometry.parent_layer and child_layer source-layer names come from mapDocument (set during map creation). Never hardcode source-layer names.zone for districts, community + community_{id} flags for COI. Layer components must use the correct key for their mode.mapModeDefaults.ts.Creating zone color expressions that assume a fixed number of zones.
Mixing district and community feature-state keys in the same layer component.
Bypassing useLayerFilter to build custom shatter filter expressions.
Rendering community layers without respecting communityVisibility state.
cd app && bun run buildcd app && bun run tszone feature-state key instead of community_{id}.beforeId anchor.