maplibre-gl-layer-control-tidop 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,796 @@
1
+ import { IControl } from 'maplibre-gl';
2
+ import { LayerSpecification } from 'maplibre-gl';
3
+ import { Map as Map_2 } from 'maplibre-gl';
4
+
5
+ /**
6
+ * Clamp a numeric value between min and max
7
+ * @param value Value to clamp
8
+ * @param min Minimum value
9
+ * @param max Maximum value
10
+ * @returns Clamped value
11
+ */
12
+ export declare function clamp(value: number, min: number, max: number): number;
13
+
14
+ /**
15
+ * Create an SVG symbol for the Background layer group
16
+ * @param size Symbol size in pixels (default: 16)
17
+ * @returns SVG markup string
18
+ */
19
+ export declare function createBackgroundGroupSymbolSVG(size?: number): string;
20
+
21
+ /**
22
+ * Create an SVG symbol for a layer type
23
+ * @param layerType The MapLibre layer type
24
+ * @param color The primary color (hex format), or null for default
25
+ * @param options Optional configuration
26
+ * @returns SVG markup string
27
+ */
28
+ export declare function createLayerSymbolSVG(layerType: string, color: string | null, options?: SymbolOptions): string;
29
+
30
+ /**
31
+ * Adapter interface for custom (non-MapLibre) layers.
32
+ * Implement this interface to integrate custom layer types (e.g., deck.gl layers)
33
+ * with the layer control.
34
+ */
35
+ export declare interface CustomLayerAdapter {
36
+ /** Unique type identifier for this adapter (e.g., 'cog', 'zarr', 'deck') */
37
+ type: string;
38
+ /** Get all layer IDs managed by this adapter */
39
+ getLayerIds(): string[];
40
+ /** Get the current state of a layer */
41
+ getLayerState(layerId: string): LayerState | null;
42
+ /** Set layer visibility */
43
+ setVisibility(layerId: string, visible: boolean): void;
44
+ /** Set layer opacity (0-1) */
45
+ setOpacity(layerId: string, opacity: number): void;
46
+ /** Get display name for a layer */
47
+ getName(layerId: string): string;
48
+ /** Get layer symbol type for UI display (optional) */
49
+ getSymbolType?(layerId: string): string;
50
+ /**
51
+ * Subscribe to layer changes (add/remove).
52
+ * Returns an unsubscribe function.
53
+ */
54
+ onLayerChange?(callback: (event: 'add' | 'remove', layerId: string) => void): () => void;
55
+ /**
56
+ * Get the bounds of a layer (optional).
57
+ * Returns [west, south, east, north] or null if not available.
58
+ */
59
+ getBounds?(layerId: string): [number, number, number, number] | null;
60
+ /**
61
+ * Remove a layer (optional).
62
+ * Called when user removes a layer via context menu.
63
+ */
64
+ removeLayer?(layerId: string): void;
65
+ /**
66
+ * Get native MapLibre layer IDs for a custom layer (optional).
67
+ * When provided, the style editor will show paint property controls
68
+ * for these native layers instead of the generic "custom layer" message.
69
+ */
70
+ getNativeLayerIds?(layerId: string): string[];
71
+ }
72
+
73
+ /**
74
+ * Registry for managing custom layer adapters.
75
+ * Routes layer operations to the appropriate adapter based on layer ID.
76
+ */
77
+ export declare class CustomLayerRegistry {
78
+ private adapters;
79
+ private changeListeners;
80
+ private unsubscribers;
81
+ /**
82
+ * Register a custom layer adapter.
83
+ * @param adapter The adapter to register
84
+ */
85
+ register(adapter: CustomLayerAdapter): void;
86
+ /**
87
+ * Unregister an adapter by type.
88
+ * @param type The adapter type to unregister
89
+ */
90
+ unregister(type: string): void;
91
+ /**
92
+ * Get all custom layer IDs across all adapters.
93
+ * @returns Array of layer IDs
94
+ */
95
+ getAllLayerIds(): string[];
96
+ /**
97
+ * Check if a layer ID is managed by any adapter.
98
+ * @param layerId The layer ID to check
99
+ * @returns true if the layer is managed by an adapter
100
+ */
101
+ hasLayer(layerId: string): boolean;
102
+ /**
103
+ * Get the adapter responsible for a specific layer.
104
+ * @param layerId The layer ID
105
+ * @returns The adapter or null if not found
106
+ */
107
+ getAdapterForLayer(layerId: string): CustomLayerAdapter | null;
108
+ /**
109
+ * Get the state of a custom layer.
110
+ * @param layerId The layer ID
111
+ * @returns The layer state or null if not found
112
+ */
113
+ getLayerState(layerId: string): LayerState | null;
114
+ /**
115
+ * Set visibility of a custom layer.
116
+ * @param layerId The layer ID
117
+ * @param visible Whether the layer should be visible
118
+ * @returns true if the operation was handled by an adapter
119
+ */
120
+ setVisibility(layerId: string, visible: boolean): boolean;
121
+ /**
122
+ * Set opacity of a custom layer.
123
+ * @param layerId The layer ID
124
+ * @param opacity The opacity value (0-1)
125
+ * @returns true if the operation was handled by an adapter
126
+ */
127
+ setOpacity(layerId: string, opacity: number): boolean;
128
+ /**
129
+ * Get the symbol type for a custom layer (for UI display).
130
+ * @param layerId The layer ID
131
+ * @returns The symbol type or null if not available
132
+ */
133
+ getSymbolType(layerId: string): string | null;
134
+ /**
135
+ * Get the bounds of a custom layer (for zoom-to-layer).
136
+ * @param layerId The layer ID
137
+ * @returns The bounds [west, south, east, north] or null if not available
138
+ */
139
+ getBounds(layerId: string): [number, number, number, number] | null;
140
+ /**
141
+ * Get native MapLibre layer IDs for a custom layer.
142
+ * @param layerId The custom layer ID
143
+ * @returns Array of native layer IDs, or null if not available
144
+ */
145
+ getNativeLayerIds(layerId: string): string[] | null;
146
+ /**
147
+ * Remove a custom layer through its adapter.
148
+ * @param layerId The layer ID to remove
149
+ * @returns true if the operation was handled by an adapter
150
+ */
151
+ removeLayer(layerId: string): boolean;
152
+ /**
153
+ * Subscribe to layer changes across all adapters.
154
+ * @param callback Function called when layers are added or removed
155
+ * @returns Unsubscribe function
156
+ */
157
+ onChange(callback: (event: 'add' | 'remove', layerId: string) => void): () => void;
158
+ private notifyChange;
159
+ /**
160
+ * Clean up all subscriptions and adapters.
161
+ */
162
+ destroy(): void;
163
+ }
164
+
165
+ /**
166
+ * Darken a hex color by a given amount
167
+ * @param hexColor The hex color to darken (e.g., '#ff0000')
168
+ * @param amount Amount to darken (0-1, where 1 is fully black)
169
+ * @returns The darkened hex color
170
+ */
171
+ export declare function darkenColor(hexColor: string, amount: number): string;
172
+
173
+ /**
174
+ * Format a numeric value based on the step size
175
+ * @param value Numeric value to format
176
+ * @param step Step size (determines decimal places)
177
+ * @returns Formatted string
178
+ */
179
+ export declare function formatNumericValue(value: number, step: number): string;
180
+
181
+ /**
182
+ * Get the primary color from a layer's paint properties
183
+ * @param map The MapLibre map instance
184
+ * @param layerId The layer ID
185
+ * @param layerType The layer type
186
+ * @returns The normalized hex color, or null if not found
187
+ */
188
+ export declare function getLayerColor(map: Map_2, layerId: string, layerType: string): string | null;
189
+
190
+ /**
191
+ * Get the primary color directly from a layer specification
192
+ * @param layer The layer specification
193
+ * @returns The normalized hex color, or null if not found
194
+ */
195
+ export declare function getLayerColorFromSpec(layer: LayerSpecification): string | null;
196
+
197
+ /**
198
+ * Get the current opacity value for a layer
199
+ * @param map MapLibre map instance
200
+ * @param layerId Layer ID
201
+ * @param layerType Layer type
202
+ * @returns Current opacity value (0-1), or 1.0 if the layer type doesn't support opacity
203
+ */
204
+ export declare function getLayerOpacity(map: Map_2, layerId: string, layerType: string): number;
205
+
206
+ /**
207
+ * Get layer type from map
208
+ * @param map MapLibre map instance
209
+ * @param layerId Layer ID
210
+ * @returns Layer type or null if layer not found
211
+ */
212
+ export declare function getLayerType(map: Map_2, layerId: string): string | null;
213
+
214
+ /**
215
+ * Check if a layer type supports style editing
216
+ * @param layerType Layer type
217
+ * @returns True if the layer type supports style editing
218
+ */
219
+ export declare function isStyleableLayerType(layerType: string): layerType is StyleableLayerType;
220
+
221
+ /**
222
+ * LayerControl - A comprehensive layer control for MapLibre GL
223
+ * Provides visibility toggle, opacity control, and advanced style editing
224
+ */
225
+ export declare class LayerControl implements IControl {
226
+ private map;
227
+ private mapContainer;
228
+ private container;
229
+ private button;
230
+ private panel;
231
+ private resizeHandler;
232
+ private mapResizeHandler;
233
+ private state;
234
+ private targetLayers;
235
+ private styleEditors;
236
+ private initialSourceIds;
237
+ private initialLayerIds;
238
+ private minPanelWidth;
239
+ private maxPanelWidth;
240
+ private maxPanelHeight;
241
+ private showStyleEditor;
242
+ private showOpacitySlider;
243
+ private showLayerSymbol;
244
+ private excludeDrawnLayers;
245
+ private excludeLayerPatterns;
246
+ private customLayerRegistry;
247
+ private customLayerUnsubscribe;
248
+ private removedCustomLayerIds;
249
+ private nativeLayerGroups;
250
+ private basemapStyleUrl;
251
+ private basemapLayerIds;
252
+ private widthSliderEl;
253
+ private widthThumbEl;
254
+ private widthValueEl;
255
+ private isWidthSliderActive;
256
+ private widthDragRectWidth;
257
+ private widthDragStartX;
258
+ private widthDragStartWidth;
259
+ private widthFrame;
260
+ private contextMenuEl;
261
+ private enableContextMenu;
262
+ private enableDragAndDrop;
263
+ private onLayerRename?;
264
+ private onLayerReorder?;
265
+ private onLayerRemove?;
266
+ constructor(options?: LayerControlOptions);
267
+ /**
268
+ * Called when the control is added to the map
269
+ */
270
+ onAdd(map: Map_2): HTMLElement;
271
+ /**
272
+ * Fetch the basemap style JSON and extract layer IDs.
273
+ * This provides reliable distinction between basemap and user-added layers.
274
+ */
275
+ private fetchBasemapStyle;
276
+ /**
277
+ * Called when the control is removed from the map
278
+ */
279
+ onRemove(): void;
280
+ /**
281
+ * Auto-detect layers from the map and populate layerStates
282
+ */
283
+ private autoDetectLayers;
284
+ /**
285
+ * Detect which sources are user-added (not from the basemap style)
286
+ * User-added sources are identified by:
287
+ * - Sources that were NOT present when the control was first added
288
+ * - Additionally for sources added later:
289
+ * - GeoJSON sources with inline data objects (not URL strings)
290
+ * - Image, video, canvas sources
291
+ * - Raster, raster-dem, vector sources from non-basemap tile providers
292
+ */
293
+ private detectUserAddedSources;
294
+ /**
295
+ * Generate a friendly display name from a layer ID
296
+ */
297
+ private generateFriendlyName;
298
+ /**
299
+ * Check if a layer ID belongs to a drawing library (Geoman, Mapbox GL Draw, etc.)
300
+ * @param layerId The layer ID to check
301
+ * @returns true if the layer is from a drawing library
302
+ */
303
+ private isDrawnLayer;
304
+ /**
305
+ * Convert wildcard patterns (e.g., '*-temp-*', 'debug-*') to RegExp objects
306
+ */
307
+ private wildcardPatternsToRegex;
308
+ /**
309
+ * Check if a layer matches any of the user-defined exclusion patterns
310
+ */
311
+ private isExcludedByPattern;
312
+ /**
313
+ * Create the main container element
314
+ */
315
+ private createContainer;
316
+ /**
317
+ * Create the toggle button
318
+ */
319
+ private createToggleButton;
320
+ /**
321
+ * Create the panel element
322
+ */
323
+ private createPanel;
324
+ /**
325
+ * Detect which corner the control is positioned in
326
+ * @returns The position: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'
327
+ */
328
+ private getControlPosition;
329
+ /**
330
+ * Update the panel position based on button location and control corner
331
+ * Positions the panel next to the button, expanding in the appropriate direction
332
+ */
333
+ private updatePanelPosition;
334
+ /**
335
+ * Create action buttons for Show All / Hide All
336
+ */
337
+ private createActionButtons;
338
+ /**
339
+ * Set visibility of all layers
340
+ */
341
+ private setAllLayersVisibility;
342
+ /**
343
+ * Create the panel header with title and width control
344
+ */
345
+ private createPanelHeader;
346
+ /**
347
+ * Create the width control slider
348
+ */
349
+ private createWidthControl;
350
+ /**
351
+ * Setup event listeners for width slider
352
+ */
353
+ private setupWidthSliderEvents;
354
+ /**
355
+ * Update panel width from pointer event
356
+ */
357
+ private updateWidthFromPointer;
358
+ /**
359
+ * Apply panel width (clamped to min/max)
360
+ */
361
+ private applyPanelWidth;
362
+ /**
363
+ * Update width display (value label and thumb position)
364
+ */
365
+ private updateWidthDisplay;
366
+ /**
367
+ * Setup main event listeners
368
+ */
369
+ private setupEventListeners;
370
+ /**
371
+ * Setup listeners for map layer changes
372
+ */
373
+ private setupLayerChangeListeners;
374
+ /**
375
+ * Toggle panel expanded/collapsed state
376
+ */
377
+ private toggle;
378
+ /**
379
+ * Expand the panel
380
+ */
381
+ private expand;
382
+ /**
383
+ * Collapse the panel
384
+ */
385
+ private collapse;
386
+ /**
387
+ * Build layer items (called initially and when layers change)
388
+ */
389
+ private buildLayerItems;
390
+ /**
391
+ * Add a single layer item to the panel
392
+ */
393
+ private addLayerItem;
394
+ /**
395
+ * Create a symbol element for a layer
396
+ * @param layerId The layer ID
397
+ * @returns The symbol HTML element, or null if layer not found
398
+ */
399
+ private createLayerSymbol;
400
+ /**
401
+ * Create a symbol element for a background layer
402
+ * @param layer The layer specification
403
+ * @returns The symbol HTML element
404
+ */
405
+ private createBackgroundLayerSymbol;
406
+ /**
407
+ * Create a symbol element for the Background layer group
408
+ * Shows a stacked layers icon to represent multiple background layers
409
+ * @returns The symbol HTML element
410
+ */
411
+ private createBackgroundGroupSymbol;
412
+ /**
413
+ * Toggle layer visibility
414
+ */
415
+ private toggleLayerVisibility;
416
+ /**
417
+ * Change layer opacity
418
+ */
419
+ private changeLayerOpacity;
420
+ /**
421
+ * Check if a layer is a user-added layer (vs basemap layer)
422
+ * Used primarily for the background legend to determine which layers are background
423
+ */
424
+ private isUserAddedLayer;
425
+ /**
426
+ * Toggle visibility for all background layers (basemap layers)
427
+ */
428
+ private toggleBackgroundVisibility;
429
+ /**
430
+ * Change opacity for all background layers (basemap layers)
431
+ */
432
+ private changeBackgroundOpacity;
433
+ /**
434
+ * Create legend button for Background layer
435
+ */
436
+ private createBackgroundLegendButton;
437
+ /**
438
+ * Toggle background legend panel visibility
439
+ */
440
+ private toggleBackgroundLegend;
441
+ /**
442
+ * Open background legend panel
443
+ */
444
+ private openBackgroundLegend;
445
+ /**
446
+ * Close background legend panel
447
+ */
448
+ private closeBackgroundLegend;
449
+ /**
450
+ * Create the background legend panel with individual layer controls
451
+ */
452
+ private createBackgroundLegendPanel;
453
+ /**
454
+ * Check if a layer is currently rendered in the map viewport
455
+ */
456
+ private isLayerRendered;
457
+ /**
458
+ * Populate the background layer list with individual layers
459
+ */
460
+ private populateBackgroundLayerList;
461
+ /**
462
+ * Toggle visibility of an individual background layer
463
+ */
464
+ private toggleIndividualBackgroundLayer;
465
+ /**
466
+ * Set visibility for all background layers
467
+ */
468
+ private setAllBackgroundLayersVisibility;
469
+ /**
470
+ * Update the main Background checkbox based on individual layer states
471
+ */
472
+ private updateBackgroundCheckboxState;
473
+ /**
474
+ * Create style button for a layer
475
+ */
476
+ private createStyleButton;
477
+ /**
478
+ * Toggle style editor for a layer
479
+ */
480
+ private toggleStyleEditor;
481
+ /**
482
+ * Open style editor for a layer
483
+ */
484
+ private openStyleEditor;
485
+ /**
486
+ * Create info panel for custom layers (style editing not supported)
487
+ */
488
+ private createCustomLayerInfoPanel;
489
+ /**
490
+ * Create a combined style editor for custom layers with native MapLibre sublayers.
491
+ * Groups controls by sublayer type (fill, line, circle, etc.).
492
+ */
493
+ private createNativeSubLayerStyleEditor;
494
+ /**
495
+ * Add style controls for a group of native layers of the same type.
496
+ * Changes to any control are applied to all layers in the group.
497
+ */
498
+ private addStyleControlsForNativeGroup;
499
+ /**
500
+ * Close style editor for a layer
501
+ */
502
+ private closeStyleEditor;
503
+ /**
504
+ * Create style editor UI
505
+ */
506
+ private createStyleEditor;
507
+ /**
508
+ * Add style controls based on layer type
509
+ */
510
+ private addStyleControlsForLayerType;
511
+ /**
512
+ * Add controls for fill layers
513
+ */
514
+ private addFillControls;
515
+ /**
516
+ * Add controls for line layers
517
+ */
518
+ private addLineControls;
519
+ /**
520
+ * Add controls for circle layers
521
+ */
522
+ private addCircleControls;
523
+ /**
524
+ * Add controls for raster layers
525
+ */
526
+ private addRasterControls;
527
+ /**
528
+ * Add controls for symbol layers
529
+ */
530
+ private addSymbolControls;
531
+ /**
532
+ * Create a color control
533
+ */
534
+ private createColorControl;
535
+ /**
536
+ * Create a slider control
537
+ */
538
+ private createSliderControl;
539
+ /**
540
+ * Reset layer style to original
541
+ */
542
+ private resetLayerStyle;
543
+ /**
544
+ * Update layer states from map (sync UI with map)
545
+ */
546
+ private updateLayerStatesFromMap;
547
+ /**
548
+ * Update UI elements for a specific layer
549
+ */
550
+ private updateUIForLayer;
551
+ /**
552
+ * Check for new layers and add them to the control, remove deleted layers
553
+ */
554
+ private checkForNewLayers;
555
+ /**
556
+ * Register a custom layer adapter dynamically.
557
+ * This allows adding adapters after the LayerControl has been initialized.
558
+ * @param adapter The custom layer adapter to register
559
+ */
560
+ registerCustomAdapter(adapter: CustomLayerAdapter): void;
561
+ /**
562
+ * Create context menu element
563
+ */
564
+ private createContextMenu;
565
+ /**
566
+ * Create a context menu item
567
+ */
568
+ private createContextMenuItem;
569
+ /**
570
+ * Show context menu at position
571
+ */
572
+ private showContextMenu;
573
+ /**
574
+ * Hide context menu
575
+ */
576
+ private hideContextMenu;
577
+ /**
578
+ * Start renaming a layer
579
+ */
580
+ private startRenaming;
581
+ /**
582
+ * Zoom to a layer's bounds
583
+ */
584
+ private zoomToLayer;
585
+ /**
586
+ * Get user layer IDs in current map order (top to bottom in UI = high z-index to low)
587
+ * Includes both MapLibre layers and custom layers managed by adapters.
588
+ */
589
+ private getUserLayerIdsInMapOrder;
590
+ /**
591
+ * Check if a layer is a MapLibre layer (not a custom layer)
592
+ */
593
+ private isMapLibreLayer;
594
+ /**
595
+ * Find the next MapLibre layer ID in a direction from a given index
596
+ * @param layerIds Array of layer IDs
597
+ * @param startIndex Index to start searching from
598
+ * @param direction 1 for forward (toward bottom), -1 for backward (toward top)
599
+ * @returns MapLibre layer ID or undefined if not found
600
+ */
601
+ private findNextMapLibreLayer;
602
+ /**
603
+ * Move a layer up in UI (higher rendering order = move to higher z-index)
604
+ */
605
+ private moveLayerUp;
606
+ /**
607
+ * Move a layer to the top (highest rendering order)
608
+ */
609
+ private moveLayerToTop;
610
+ /**
611
+ * Move a layer down in UI (lower rendering order = move to lower z-index)
612
+ */
613
+ private moveLayerDown;
614
+ /**
615
+ * Move a layer to the bottom (lowest rendering order among user layers)
616
+ */
617
+ private moveLayerToBottom;
618
+ /**
619
+ * Remove a layer from the map
620
+ */
621
+ private removeLayer;
622
+ /**
623
+ * Create drag handle element
624
+ */
625
+ private createDragHandle;
626
+ /**
627
+ * Create a disabled drag handle for alignment (used for Background layer)
628
+ */
629
+ private createDisabledDragHandle;
630
+ /**
631
+ * Start dragging a layer
632
+ */
633
+ private startDrag;
634
+ /**
635
+ * Handle drag move
636
+ */
637
+ private onDragMove;
638
+ /**
639
+ * End dragging
640
+ */
641
+ private endDrag;
642
+ /**
643
+ * Clean up drag state
644
+ */
645
+ private cleanupDragState;
646
+ /**
647
+ * Apply UI order to map layers
648
+ */
649
+ private applyUIOrderToMap;
650
+ }
651
+
652
+ /**
653
+ * Options for LayerControl constructor
654
+ */
655
+ export declare interface LayerControlOptions {
656
+ /** Whether the control starts collapsed (default: true) */
657
+ collapsed?: boolean;
658
+ /** Initial layer states (keyed by layer ID) */
659
+ layerStates?: LayerStates;
660
+ /** Array of layer IDs to control (if not specified, controls all layers) */
661
+ layers?: string[];
662
+ /** Initial panel width in pixels (default: 320) */
663
+ panelWidth?: number;
664
+ /** Minimum panel width in pixels (default: 240) */
665
+ panelMinWidth?: number;
666
+ /** Maximum panel width in pixels (default: 420) */
667
+ panelMaxWidth?: number;
668
+ /** Whether to show the style editor button (gear icon) for layers (default: true) */
669
+ showStyleEditor?: boolean;
670
+ /** Whether to show the opacity slider for layers (default: true) */
671
+ showOpacitySlider?: boolean;
672
+ /** Whether to show layer type symbols/icons next to layer names (default: true) */
673
+ showLayerSymbol?: boolean;
674
+ /** Maximum panel height in pixels (default: 600). When content exceeds this height, the panel becomes scrollable. */
675
+ panelMaxHeight?: number;
676
+ /** Whether to exclude drawn layers from drawing libraries like Geoman, Mapbox GL Draw, etc. (default: true) */
677
+ excludeDrawnLayers?: boolean;
678
+ /** Array of wildcard patterns to exclude layers by name (e.g., ['*-temp-*', 'debug-*']) */
679
+ excludeLayers?: string[];
680
+ /** Custom layer adapters for non-MapLibre layers (e.g., deck.gl COG layers, Zarr layers) */
681
+ customLayerAdapters?: CustomLayerAdapter[];
682
+ /**
683
+ * URL of the basemap style JSON. If provided, all layers defined in this style
684
+ * will be grouped under "Background", and all other layers will be shown individually
685
+ * in the layer control. This provides reliable distinction between basemap layers
686
+ * and user-added layers.
687
+ */
688
+ basemapStyleUrl?: string;
689
+ /** Whether to enable context menu (right-click) on layers (default: true) */
690
+ enableContextMenu?: boolean;
691
+ /** Whether to enable drag-and-drop reordering of layers (default: true) */
692
+ enableDragAndDrop?: boolean;
693
+ /** Callback when a layer is renamed via context menu */
694
+ onLayerRename?: (layerId: string, oldName: string, newName: string) => void;
695
+ /** Callback when layers are reordered via drag-and-drop */
696
+ onLayerReorder?: (layerOrder: string[]) => void;
697
+ /** Callback when a layer is removed via context menu */
698
+ onLayerRemove?: (layerId: string) => void;
699
+ }
700
+
701
+ /**
702
+ * State for a single layer
703
+ */
704
+ export declare interface LayerState {
705
+ /** Whether the layer is visible */
706
+ visible: boolean;
707
+ /** Layer opacity (0-1) */
708
+ opacity: number;
709
+ /** Display name for the layer */
710
+ name: string;
711
+ /** Whether this is a custom (non-MapLibre) layer */
712
+ isCustomLayer?: boolean;
713
+ /** Custom layer type identifier (e.g., 'cog', 'zarr') */
714
+ customLayerType?: string;
715
+ }
716
+
717
+ /**
718
+ * Collection of layer states keyed by layer ID
719
+ */
720
+ export declare interface LayerStates {
721
+ [layerId: string]: LayerState;
722
+ }
723
+
724
+ /**
725
+ * Normalize a color value to hex format
726
+ * Handles hex strings, RGB strings, and RGB arrays
727
+ * @param value Color value in various formats
728
+ * @returns Normalized hex color string (always 6 digits)
729
+ */
730
+ export declare function normalizeColor(value: any): string;
731
+
732
+ /**
733
+ * Paint properties for different layer types
734
+ */
735
+ export declare interface PaintProperty {
736
+ /** Property name (e.g., 'fill-color') */
737
+ name: string;
738
+ /** Current value */
739
+ value: any;
740
+ }
741
+
742
+ /**
743
+ * Convert RGB values to hex color string
744
+ * @param r Red component (0-255)
745
+ * @param g Green component (0-255)
746
+ * @param b Blue component (0-255)
747
+ * @returns Hex color string (e.g., '#ff0000')
748
+ */
749
+ export declare function rgbToHex(r: number, g: number, b: number): string;
750
+
751
+ /**
752
+ * Set the opacity for a layer
753
+ * @param map MapLibre map instance
754
+ * @param layerId Layer ID
755
+ * @param layerType Layer type
756
+ * @param opacity Opacity value (0-1)
757
+ */
758
+ export declare function setLayerOpacity(map: Map_2, layerId: string, layerType: string, opacity: number): void;
759
+
760
+ /**
761
+ * MapLibre layer types that support styling
762
+ * Includes all standard MapLibre layer types
763
+ */
764
+ export declare type StyleableLayerType = 'fill' | 'line' | 'circle' | 'symbol' | 'raster' | 'heatmap' | 'fill-extrusion' | 'hillshade' | 'background';
765
+
766
+ /**
767
+ * Control for a paint property (color picker or slider)
768
+ */
769
+ export declare interface StyleControlConfig {
770
+ /** Label to display */
771
+ label: string;
772
+ /** Paint property name */
773
+ property: string;
774
+ /** Control type */
775
+ type: 'color' | 'slider';
776
+ /** For sliders: minimum value */
777
+ min?: number;
778
+ /** For sliders: maximum value */
779
+ max?: number;
780
+ /** For sliders: step increment */
781
+ step?: number;
782
+ /** Default value if property is not set */
783
+ defaultValue?: any;
784
+ }
785
+
786
+ /**
787
+ * Symbol generation options
788
+ */
789
+ export declare interface SymbolOptions {
790
+ /** Symbol size in pixels (default: 16) */
791
+ size?: number;
792
+ /** Stroke width for line symbols (default: 2) */
793
+ strokeWidth?: number;
794
+ }
795
+
796
+ export { }