Skip to content

Commit ab4fddc

Browse files
committed
Refactor layer config: dynamic map & UI generation
1 parent 9c4f45d commit ab4fddc

File tree

4 files changed

+572
-493
lines changed

4 files changed

+572
-493
lines changed

app/index.html

Lines changed: 8 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -35,50 +35,18 @@
3535
<div id="menu">
3636
<div class="menu-section">
3737
<label class="section-title">Overlays</label>
38-
<div class="checkbox-group">
39-
<label>
40-
<input id="carbon-layer" type="checkbox" name="rtoggle" value="carbon">
41-
<span>Vulnerable Carbon</span>
42-
</label>
43-
<label>
44-
<input id="species-richness-layer" type="checkbox" name="rtoggle" value="species_richness">
45-
<span>🦜 Species Richness</span>
46-
</label>
47-
<div id="species-richness-controls" class="layer-controls"
48-
style="display: none; margin-left: 20px; margin-top: 5px;">
49-
<div style="margin-bottom: 8px;">
50-
<label style="font-size: 11px; color: #666; display: block; margin-bottom: 3px;">Species
51-
Type:</label>
52-
<label style="font-size: 12px; margin-right: 10px;">
53-
<input type="radio" name="species-type" value="all" checked>
54-
<span>All Species</span>
55-
</label>
56-
<label style="font-size: 12px;">
57-
<input type="radio" name="species-type" value="threatened">
58-
<span>Threatened</span>
59-
</label>
60-
</div>
61-
<div>
62-
<label style="font-size: 11px; color: #666; display: block; margin-bottom: 3px;">Taxonomic
63-
Group:</label>
64-
<select id="species-taxon" style="width: 100%; font-size: 12px;">
65-
<option value="combined">🌍 All Groups</option>
66-
<option value="amphibians">🐸 Amphibians</option>
67-
<option value="birds">🦜 Birds</option>
68-
<option value="mammals">🦁 Mammals</option>
69-
<option value="reptiles">🦎 Reptiles</option>
70-
<option value="fw_fish">🐟 Freshwater Fish</option>
71-
</select>
72-
</div>
73-
</div>
74-
<label>
75-
<input id="wdpa-layer" type="checkbox" name="rtoggle" value="wdpa">
76-
<span>Protected Areas (WDPA)</span>
77-
</label>
38+
<div id="layer-controls-container" class="checkbox-group">
39+
<!-- Layers will be generated dynamically -->
7840
</div>
7941
</div>
8042
</div>
8143

44+
<script type="module">
45+
import { UILayerGenerator } from './ui-layer-generator.js';
46+
47+
// Expose to window for debugging if needed
48+
window.UILayerGenerator = UILayerGenerator;
49+
</script>
8250
<script type="module" src="map.js"></script>
8351
<script type="module" src="chat.js"></script>
8452
</body>

app/layers-config.json

Lines changed: 227 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,233 @@
22
"version": "1.0",
33
"description": "Map layer configuration for California Protected Lands application",
44
"layers": {
5+
"carbon": {
6+
"displayName": "Vulnerable Carbon",
7+
"layerIds": [
8+
"carbon-layer"
9+
],
10+
"checkboxId": "carbon-layer",
11+
"hasLegend": false,
12+
"isVector": false,
13+
"source": {
14+
"type": "raster",
15+
"tiles": [
16+
"https://titiler.nrp-nautilus.io/cog/tiles/WebMercatorQuad/{z}/{x}/{y}.png?url=https://s3-west.nrp-nautilus.io/public-carbon/cogs/vulnerable_c_total_2018.tif&colormap_name=reds"
17+
],
18+
"tileSize": 256,
19+
"minzoom": 0,
20+
"maxzoom": 12,
21+
"attribution": "<a href=\"https://www.conservation.org/irrecoverable-carbon\" target=\"_blank\">Irrecoverable Carbon (CI 2018)</a>"
22+
},
23+
"layer": {
24+
"type": "raster",
25+
"paint": {
26+
"raster-opacity": 0.7
27+
},
28+
"layout": {
29+
"visibility": "none"
30+
}
31+
}
32+
},
33+
"species_richness": {
34+
"displayName": "🦜 Species Richness",
35+
"layerIds": [
36+
"species-richness-layer"
37+
],
38+
"checkboxId": "species-richness-layer",
39+
"hasLegend": false,
40+
"isVector": false,
41+
"source": {
42+
"type": "raster",
43+
"tiles": [
44+
"https://titiler.xyz/cog/tiles/WebMercatorQuad/{z}/{x}/{y}@1x?url=https://s3-west.nrp-nautilus.io/public-iucn/cog/richness/Combined_SR_2025.tif&rescale=0,800&colormap_name=turbo"
45+
],
46+
"tileSize": 256,
47+
"minzoom": 0,
48+
"maxzoom": 12,
49+
"attribution": "<a href=\"https://www.iucnredlist.org/\" target=\"_blank\">IUCN Red List 2025</a>"
50+
},
51+
"layer": {
52+
"type": "raster",
53+
"paint": {
54+
"raster-opacity": 0.7
55+
},
56+
"layout": {
57+
"visibility": "none"
58+
}
59+
},
60+
"params": {
61+
"species_type": {
62+
"type": "radio",
63+
"label": "Species Type:",
64+
"options": [
65+
{
66+
"value": "all",
67+
"label": "All Species",
68+
"default": true
69+
},
70+
{
71+
"value": "threatened",
72+
"label": "Threatened"
73+
}
74+
]
75+
},
76+
"taxon": {
77+
"type": "select",
78+
"label": "Taxonomic Group:",
79+
"options": [
80+
{
81+
"value": "combined",
82+
"label": "🌍 All Groups",
83+
"default": true
84+
},
85+
{
86+
"value": "amphibians",
87+
"label": "🐸 Amphibians"
88+
},
89+
{
90+
"value": "birds",
91+
"label": "🦜 Birds"
92+
},
93+
{
94+
"value": "mammals",
95+
"label": "🦁 Mammals"
96+
},
97+
{
98+
"value": "reptiles",
99+
"label": "🦎 Reptiles"
100+
},
101+
{
102+
"value": "fw_fish",
103+
"label": "🐟 Freshwater Fish"
104+
}
105+
]
106+
}
107+
}
108+
},
109+
"wdpa": {
110+
"displayName": "Protected Areas (WDPA)",
111+
"layerIds": [
112+
"wdpa-layer"
113+
],
114+
"checkboxId": "wdpa-layer",
115+
"hasLegend": false,
116+
"isVector": true,
117+
"source": {
118+
"type": "vector",
119+
"url": "pmtiles://https://s3-west.nrp-nautilus.io/public-wdpa/WDPA_Dec2025.pmtiles",
120+
"attribution": "<a href=\"https://www.protectedplanet.net/\" target=\"_blank\">World Database on Protected Areas</a>"
121+
},
122+
"layer": {
123+
"type": "fill",
124+
"source-layer": "wdpa",
125+
"minzoom": 0,
126+
"maxzoom": 22,
127+
"paint": {
128+
"fill-color": "#2E7D32",
129+
"fill-opacity": 0.5
130+
},
131+
"layout": {
132+
"visibility": "none"
133+
}
134+
},
135+
"popup": {
136+
"title": "{NAME_ENG} || {NAME} || Protected Area",
137+
"fields": [
138+
{
139+
"label": "Type",
140+
"property": "DESIG_ENG"
141+
},
142+
{
143+
"label": "IUCN Category",
144+
"property": "IUCN_CAT"
145+
},
146+
{
147+
"label": "Ownership",
148+
"property": "OWN_TYPE"
149+
},
150+
{
151+
"label": "Area",
152+
"property": "GIS_AREA",
153+
"suffix": " km²"
154+
},
155+
{
156+
"label": "Year",
157+
"property": "STATUS_YR"
158+
}
159+
]
160+
},
161+
"filterableProperties": {
162+
"NAME_ENG": {
163+
"type": "string",
164+
"description": "Site name in English"
165+
},
166+
"NAME": {
167+
"type": "string",
168+
"description": "Site name (original)"
169+
},
170+
"DESIG_ENG": {
171+
"type": "string",
172+
"description": "Designation type in English"
173+
},
174+
"DESIG_TYPE": {
175+
"type": "string",
176+
"description": "Designation type category"
177+
},
178+
"IUCN_CAT": {
179+
"type": "string",
180+
"description": "IUCN management category",
181+
"values": [
182+
"Ia",
183+
"Ib",
184+
"II",
185+
"III",
186+
"IV",
187+
"V",
188+
"VI",
189+
"Not Reported",
190+
"Not Applicable",
191+
"Not Assigned"
192+
]
193+
},
194+
"ISO3": {
195+
"type": "string",
196+
"description": "ISO 3-letter country code"
197+
},
198+
"STATUS": {
199+
"type": "string",
200+
"description": "Current status (e.g., Designated, Proposed)"
201+
},
202+
"STATUS_YR": {
203+
"type": "number",
204+
"description": "Year of status"
205+
},
206+
"GOV_TYPE": {
207+
"type": "string",
208+
"description": "Governance type"
209+
},
210+
"OWN_TYPE": {
211+
"type": "string",
212+
"description": "Ownership type"
213+
},
214+
"GIS_AREA": {
215+
"type": "number",
216+
"description": "GIS-calculated area in km²"
217+
},
218+
"REP_AREA": {
219+
"type": "number",
220+
"description": "Reported area in km²"
221+
},
222+
"MARINE": {
223+
"type": "string",
224+
"description": "Marine designation (0, 1, 2)"
225+
},
226+
"NO_TAKE": {
227+
"type": "string",
228+
"description": "No-take zone status"
229+
}
230+
}
231+
},
5232
"cpad": {
6233
"displayName": "California Protected Areas (CPAD)",
7234
"layerIds": [

0 commit comments

Comments
 (0)