-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathmapboxStyleLayers.ts
More file actions
784 lines (756 loc) · 18.7 KB
/
mapboxStyleLayers.ts
File metadata and controls
784 lines (756 loc) · 18.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
/**
* Mapbox Style Layer Definitions
*
* Comprehensive descriptions of all Mapbox style layers to guide LLMs in creating styles.
* Based on Mapbox Streets v12 specification.
*/
export interface LayerDefinition {
id: string;
description: string;
sourceLayer?: string;
type:
| 'background'
| 'fill'
| 'line'
| 'symbol'
| 'circle'
| 'raster'
| 'hillshade'
| 'heatmap'
| 'fill-extrusion'
| 'sky';
commonFilters?: string[];
availableProperties?: Record<
string,
{
description: string;
values?: string[];
type?: 'string' | 'number' | 'boolean';
}
>;
paintProperties: {
property: string;
description: string;
example: unknown;
}[];
layoutProperties?: {
property: string;
description: string;
example: unknown;
}[];
examples: string[];
}
export const MAPBOX_STYLE_LAYERS: Record<string, LayerDefinition> = {
// Background layers
land: {
id: 'land',
description:
'Background layer for land/terrain. Sets the base color of the map.',
type: 'background',
paintProperties: [
{
property: 'background-color',
description: 'Color of the land/background',
example: '#f8f4f0'
}
],
examples: [
'Create a dark mode map with black land',
'Make the background beige'
]
},
// Water features
water: {
id: 'water',
description: 'Fill layer for water bodies like oceans, lakes, and rivers',
sourceLayer: 'water',
type: 'fill',
paintProperties: [
{
property: 'fill-color',
description: 'Color of water bodies',
example: '#73b6e6'
},
{
property: 'fill-opacity',
description: 'Opacity of water (0-1)',
example: 1
}
],
examples: [
'Change water to yellow',
'Make oceans dark blue',
'Set lakes to turquoise'
]
},
waterway: {
id: 'waterway',
description: 'Line layer for rivers, streams, and canals',
sourceLayer: 'waterway',
type: 'line',
commonFilters: ['class: river, stream, canal'],
paintProperties: [
{
property: 'line-color',
description: 'Color of waterways',
example: '#73b6e6'
},
{
property: 'line-width',
description: 'Width of waterway lines',
example: ['interpolate', ['exponential', 1.3], ['zoom'], 8, 0.5, 20, 6]
}
],
examples: [
'Highlight rivers in bright blue',
'Make streams wider',
'Show canals in green'
]
},
// Landuse and land cover
parks: {
id: 'landuse_park',
description: 'Fill layer for parks, gardens, and green spaces',
sourceLayer: 'landuse',
type: 'fill',
commonFilters: ['class: park, cemetery, golf_course'],
paintProperties: [
{
property: 'fill-color',
description: 'Color of parks and green spaces',
example: '#d8e8c8'
},
{
property: 'fill-opacity',
description: 'Opacity of parks',
example: 0.9
}
],
examples: [
'Highlight parks in bright green',
'Make parks darker',
'Show golf courses in different shade'
]
},
buildings: {
id: 'building',
description: 'Fill or fill-extrusion layer for buildings',
sourceLayer: 'building',
type: 'fill',
paintProperties: [
{
property: 'fill-color',
description: 'Color of buildings',
example: '#e0d8ce'
},
{
property: 'fill-opacity',
description: 'Opacity of buildings',
example: ['interpolate', ['linear'], ['zoom'], 15, 0, 16, 1]
}
],
examples: [
'Show buildings in red',
'Make buildings semi-transparent',
'Hide buildings at low zoom'
]
},
building_3d: {
id: 'building-3d',
description: '3D extrusion layer for buildings',
sourceLayer: 'building',
type: 'fill-extrusion',
paintProperties: [
{
property: 'fill-extrusion-color',
description: 'Color of 3D buildings',
example: '#e0d8ce'
},
{
property: 'fill-extrusion-height',
description: 'Height of buildings',
example: ['get', 'height']
},
{
property: 'fill-extrusion-base',
description: 'Base height of buildings',
example: ['get', 'min_height']
}
],
examples: [
'Create 3D buildings',
'Make buildings taller',
'Color buildings by height'
]
},
// Transportation
railways: {
id: 'road-rail',
description: 'Line layer for railway tracks and rail lines',
sourceLayer: 'road',
type: 'line',
commonFilters: ['class: major_rail, minor_rail, service_rail'],
paintProperties: [
{
property: 'line-color',
description: 'Color of railway lines',
example: '#bbb'
},
{
property: 'line-width',
description: 'Width of railway lines',
example: ['interpolate', ['exponential', 1.5], ['zoom'], 14, 0.5, 20, 2]
}
],
layoutProperties: [
{
property: 'line-join',
description: 'Line join style',
example: 'round'
}
],
examples: [
'Highlight railways in red',
'Make train tracks thicker',
'Show metro lines differently'
]
},
motorways: {
id: 'road-motorway',
description: 'Line layer for highways and motorways',
sourceLayer: 'road',
type: 'line',
commonFilters: ['class: motorway, trunk'],
paintProperties: [
{
property: 'line-color',
description: 'Color of highways',
example: '#fc8'
},
{
property: 'line-width',
description: 'Width of highway lines',
example: ['interpolate', ['exponential', 1.5], ['zoom'], 5, 0.5, 18, 30]
}
],
examples: [
'Make highways orange',
'Widen motorways',
'Highlight major roads'
]
},
primary_roads: {
id: 'road-primary',
description: 'Line layer for primary/main roads',
sourceLayer: 'road',
type: 'line',
commonFilters: ['class: primary'],
paintProperties: [
{
property: 'line-color',
description: 'Color of primary roads',
example: '#fea'
},
{
property: 'line-width',
description: 'Width of primary roads',
example: ['interpolate', ['exponential', 1.5], ['zoom'], 5, 0.5, 18, 26]
}
],
examples: ['Color main roads yellow', 'Make primary roads prominent']
},
secondary_roads: {
id: 'road-secondary',
description: 'Line layer for secondary roads',
sourceLayer: 'road',
type: 'line',
commonFilters: ['class: secondary, tertiary'],
paintProperties: [
{
property: 'line-color',
description: 'Color of secondary roads',
example: '#fff'
},
{
property: 'line-width',
description: 'Width of secondary roads',
example: [
'interpolate',
['exponential', 1.5],
['zoom'],
11,
0.5,
18,
20
]
}
],
examples: ['Show secondary roads in gray', 'Make minor roads thinner']
},
streets: {
id: 'road-street',
description: 'Line layer for local streets',
sourceLayer: 'road',
type: 'line',
commonFilters: ['class: street, street_limited, residential, service'],
paintProperties: [
{
property: 'line-color',
description: 'Color of streets',
example: '#fff'
},
{
property: 'line-width',
description: 'Width of streets',
example: [
'interpolate',
['exponential', 1.5],
['zoom'],
12,
0.5,
18,
12
]
}
],
examples: [
'Color residential streets',
'Hide small streets',
'Make local roads visible'
]
},
paths: {
id: 'road-path',
description: 'Line layer for pedestrian paths, footways, and trails',
sourceLayer: 'road',
type: 'line',
commonFilters: ['class: path, pedestrian'],
paintProperties: [
{
property: 'line-color',
description: 'Color of paths',
example: '#cba'
},
{
property: 'line-width',
description: 'Width of paths',
example: ['interpolate', ['exponential', 1.5], ['zoom'], 15, 1, 18, 4]
},
{
property: 'line-dasharray',
description: 'Dash pattern for paths',
example: [1, 1]
}
],
examples: [
'Show walking paths as dotted lines',
'Highlight hiking trails',
'Color bike paths green'
]
},
tunnels: {
id: 'tunnel',
description: 'Line layers for roads in tunnels (with special styling)',
sourceLayer: 'road',
type: 'line',
commonFilters: ['structure: tunnel'],
paintProperties: [
{
property: 'line-color',
description: 'Color of tunnel roads',
example: '#fff'
},
{
property: 'line-opacity',
description: 'Opacity of tunnel roads (usually reduced)',
example: 0.5
},
{
property: 'line-dasharray',
description: 'Dash pattern for tunnels',
example: [0.4, 0.4]
}
],
examples: ['Make tunnels semi-transparent', 'Show tunnels as dashed lines']
},
bridges: {
id: 'bridge',
description: 'Line layers for roads on bridges (with special casing)',
sourceLayer: 'road',
type: 'line',
commonFilters: ['structure: bridge'],
paintProperties: [
{
property: 'line-color',
description: 'Color of bridge roads',
example: '#fff'
},
{
property: 'line-width',
description: 'Width of bridges (usually wider than regular roads)',
example: ['interpolate', ['exponential', 1.5], ['zoom'], 12, 1, 18, 30]
}
],
examples: [
'Highlight bridges',
'Make bridge outlines thicker',
'Color bridges differently'
]
},
airports: {
id: 'aeroway',
description: 'Fill and line layers for airport runways and taxiways',
sourceLayer: 'aeroway',
type: 'fill',
paintProperties: [
{
property: 'fill-color',
description: 'Color of airport areas',
example: '#ddd'
},
{
property: 'fill-opacity',
description: 'Opacity of airport areas',
example: 1
}
],
examples: [
'Show airports in gray',
'Highlight runways',
'Make airport areas visible'
]
},
// Administrative boundaries
country_boundaries: {
id: 'admin-0-boundary',
description:
'Line layer for country/nation boundaries (from admin source-layer)',
sourceLayer: 'admin',
type: 'line',
commonFilters: ['admin_level: 0', 'maritime: false', 'disputed: false'],
paintProperties: [
{
property: 'line-color',
description: 'Color of country borders',
example: '#8b8aba'
},
{
property: 'line-width',
description: 'Width of country borders',
example: ['interpolate', ['linear'], ['zoom'], 3, 0.5, 10, 2]
},
{
property: 'line-dasharray',
description: 'Dash pattern for disputed borders',
example: [2, 2]
}
],
examples: [
'Make country borders red',
'Show disputed boundaries as dashed',
'Thicken international borders'
]
},
state_boundaries: {
id: 'admin-1-boundary',
description:
'Line layer for state/province boundaries (from admin source-layer)',
sourceLayer: 'admin',
type: 'line',
commonFilters: ['admin_level: 1', 'maritime: false'],
paintProperties: [
{
property: 'line-color',
description: 'Color of state borders',
example: '#9e9cab'
},
{
property: 'line-width',
description: 'Width of state borders',
example: ['interpolate', ['linear'], ['zoom'], 3, 0.3, 10, 1.5]
}
],
examples: [
'Show state boundaries',
'Make province borders visible',
'Color regional boundaries'
]
},
disputed_boundaries: {
id: 'admin-disputed',
description: 'Line layer for disputed boundaries',
sourceLayer: 'admin',
type: 'line',
commonFilters: ['disputed: 1'],
paintProperties: [
{
property: 'line-color',
description: 'Color of disputed borders',
example: '#ff0000'
},
{
property: 'line-width',
description: 'Width of disputed borders',
example: 2
},
{
property: 'line-dasharray',
description: 'Dash pattern for disputed borders',
example: [2, 4]
}
],
examples: ['Show disputed territories', 'Highlight contested borders']
},
// Labels
place_labels: {
id: 'place-label',
description: 'Symbol layer for city, town, and place name labels',
sourceLayer: 'place_label',
type: 'symbol',
commonFilters: ['class: settlement, city, town, village'],
layoutProperties: [
{
property: 'text-field',
description: 'Text to display',
example: ['get', 'name']
},
{
property: 'text-font',
description: 'Font family',
example: ['DIN Pro Medium', 'Arial Unicode MS Regular']
},
{
property: 'text-size',
description: 'Text size',
example: ['interpolate', ['linear'], ['zoom'], 10, 12, 18, 24]
}
],
paintProperties: [
{
property: 'text-color',
description: 'Color of place labels',
example: '#333'
},
{
property: 'text-halo-color',
description: 'Color of text halo/outline',
example: '#fff'
},
{
property: 'text-halo-width',
description: 'Width of text halo',
example: 1.5
}
],
examples: [
'Hide city names',
'Make town labels larger',
'Color place names blue'
]
},
road_labels: {
id: 'road-label',
description: 'Symbol layer for road name labels',
sourceLayer: 'road',
type: 'symbol',
layoutProperties: [
{
property: 'symbol-placement',
description: 'Label placement strategy',
example: 'line'
},
{
property: 'text-field',
description: 'Road name text',
example: ['get', 'name']
},
{
property: 'text-font',
description: 'Font for road names',
example: ['DIN Pro Regular', 'Arial Unicode MS Regular']
},
{
property: 'text-size',
description: 'Size of road labels',
example: 12
},
{
property: 'text-rotation-alignment',
description: 'Text rotation alignment',
example: 'map'
}
],
paintProperties: [
{
property: 'text-color',
description: 'Color of road labels',
example: '#666'
},
{
property: 'text-halo-color',
description: 'Halo color for road labels',
example: '#fff'
}
],
examples: [
'Show street names',
'Hide road labels',
'Make road names bigger'
]
},
poi_labels: {
id: 'poi-label',
description: 'Symbol layer for points of interest (POI) labels',
sourceLayer: 'poi_label',
type: 'symbol',
commonFilters: ['class: park, hospital, school, museum, etc.'],
layoutProperties: [
{
property: 'text-field',
description: 'POI name',
example: ['get', 'name']
},
{
property: 'icon-image',
description: 'Icon for POI',
example: ['get', 'maki']
},
{
property: 'text-anchor',
description: 'Text anchor position',
example: 'top'
}
],
paintProperties: [
{
property: 'text-color',
description: 'Color of POI labels',
example: '#666'
},
{
property: 'icon-opacity',
description: 'Opacity of POI icons',
example: 1
}
],
examples: [
'Show restaurant names',
'Hide POI labels',
'Display park names in green'
]
},
transit: {
id: 'transit',
description: 'Symbol layer for transit stations and stops',
sourceLayer: 'transit_stop_label',
type: 'symbol',
layoutProperties: [
{
property: 'text-field',
description: 'Station name',
example: ['get', 'name']
},
{
property: 'icon-image',
description: 'Transit icon',
example: ['get', 'network']
}
],
paintProperties: [
{
property: 'text-color',
description: 'Color of transit labels',
example: '#4898ff'
}
],
examples: [
'Show subway stations',
'Highlight bus stops',
'Display train stations prominently'
]
}
};
// Helper function to get layer suggestions based on user input
export function getLayerSuggestions(userPrompt: string): string[] {
const prompt = userPrompt.toLowerCase();
const suggestions: string[] = [];
Object.entries(MAPBOX_STYLE_LAYERS).forEach(([key, layer]) => {
// Check if the prompt mentions this layer type
const keywords = [
key,
layer.id,
layer.sourceLayer,
...layer.examples.join(' ').toLowerCase().split(' ')
].filter(Boolean);
if (keywords.some((keyword) => prompt.includes(keyword as string))) {
suggestions.push(key);
}
});
// Add specific keyword mappings
if (
prompt.includes('water') ||
prompt.includes('ocean') ||
prompt.includes('sea') ||
prompt.includes('lake')
) {
suggestions.push('water', 'waterway');
}
if (
prompt.includes('park') ||
prompt.includes('green') ||
prompt.includes('garden')
) {
suggestions.push('parks');
}
if (
prompt.includes('railway') ||
prompt.includes('train') ||
prompt.includes('rail') ||
prompt.includes('metro')
) {
suggestions.push('railways');
}
if (
prompt.includes('road') ||
prompt.includes('street') ||
prompt.includes('highway') ||
prompt.includes('motorway')
) {
suggestions.push(
'motorways',
'primary_roads',
'secondary_roads',
'streets'
);
}
if (
prompt.includes('building') ||
prompt.includes('house') ||
prompt.includes('3d')
) {
suggestions.push('buildings', 'building_3d');
}
if (
prompt.includes('label') ||
prompt.includes('name') ||
prompt.includes('text')
) {
suggestions.push('place_labels', 'road_labels', 'poi_labels');
}
if (
prompt.includes('country') ||
prompt.includes('border') ||
prompt.includes('boundary')
) {
suggestions.push('country_boundaries', 'state_boundaries');
}
if (
prompt.includes('transit') ||
prompt.includes('subway') ||
prompt.includes('bus') ||
prompt.includes('station')
) {
suggestions.push('transit');
}
return [...new Set(suggestions)];
}