maplibre-gl-layer-control 0.5.0 → 0.6.0

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.
@@ -894,3 +894,15 @@
894
894
  .background-legend-layer-list::-webkit-scrollbar-thumb:hover {
895
895
  background: #a8a8a8;
896
896
  }
897
+
898
+ /* Custom layer info panel */
899
+ .layer-control-custom-info-text {
900
+ margin: 0;
901
+ padding: 8px;
902
+ font-size: 11px;
903
+ line-height: 1.5;
904
+ color: #666;
905
+ background: #f0f4f8;
906
+ border-radius: 4px;
907
+ border-left: 3px solid #2f6fed;
908
+ }
@@ -27,6 +27,107 @@ export declare function createBackgroundGroupSymbolSVG(size?: number): string;
27
27
  */
28
28
  export declare function createLayerSymbolSVG(layerType: string, color: string | null, options?: SymbolOptions): string;
29
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
+
57
+ /**
58
+ * Registry for managing custom layer adapters.
59
+ * Routes layer operations to the appropriate adapter based on layer ID.
60
+ */
61
+ export declare class CustomLayerRegistry {
62
+ private adapters;
63
+ private changeListeners;
64
+ private unsubscribers;
65
+ /**
66
+ * Register a custom layer adapter.
67
+ * @param adapter The adapter to register
68
+ */
69
+ register(adapter: CustomLayerAdapter): void;
70
+ /**
71
+ * Unregister an adapter by type.
72
+ * @param type The adapter type to unregister
73
+ */
74
+ unregister(type: string): void;
75
+ /**
76
+ * Get all custom layer IDs across all adapters.
77
+ * @returns Array of layer IDs
78
+ */
79
+ getAllLayerIds(): string[];
80
+ /**
81
+ * Check if a layer ID is managed by any adapter.
82
+ * @param layerId The layer ID to check
83
+ * @returns true if the layer is managed by an adapter
84
+ */
85
+ hasLayer(layerId: string): boolean;
86
+ /**
87
+ * Get the adapter responsible for a specific layer.
88
+ * @param layerId The layer ID
89
+ * @returns The adapter or null if not found
90
+ */
91
+ getAdapterForLayer(layerId: string): CustomLayerAdapter | null;
92
+ /**
93
+ * Get the state of a custom layer.
94
+ * @param layerId The layer ID
95
+ * @returns The layer state or null if not found
96
+ */
97
+ getLayerState(layerId: string): LayerState | null;
98
+ /**
99
+ * Set visibility of a custom layer.
100
+ * @param layerId The layer ID
101
+ * @param visible Whether the layer should be visible
102
+ * @returns true if the operation was handled by an adapter
103
+ */
104
+ setVisibility(layerId: string, visible: boolean): boolean;
105
+ /**
106
+ * Set opacity of a custom layer.
107
+ * @param layerId The layer ID
108
+ * @param opacity The opacity value (0-1)
109
+ * @returns true if the operation was handled by an adapter
110
+ */
111
+ setOpacity(layerId: string, opacity: number): boolean;
112
+ /**
113
+ * Get the symbol type for a custom layer (for UI display).
114
+ * @param layerId The layer ID
115
+ * @returns The symbol type or null if not available
116
+ */
117
+ getSymbolType(layerId: string): string | null;
118
+ /**
119
+ * Subscribe to layer changes across all adapters.
120
+ * @param callback Function called when layers are added or removed
121
+ * @returns Unsubscribe function
122
+ */
123
+ onChange(callback: (event: 'add' | 'remove', layerId: string) => void): () => void;
124
+ private notifyChange;
125
+ /**
126
+ * Clean up all subscriptions and adapters.
127
+ */
128
+ destroy(): void;
129
+ }
130
+
30
131
  /**
31
132
  * Darken a hex color by a given amount
32
133
  * @param hexColor The hex color to darken (e.g., '#ff0000')
@@ -102,6 +203,8 @@ export declare class LayerControl implements IControl {
102
203
  private showOpacitySlider;
103
204
  private showLayerSymbol;
104
205
  private excludeDrawnLayers;
206
+ private customLayerRegistry;
207
+ private customLayerUnsubscribe;
105
208
  private widthSliderEl;
106
209
  private widthThumbEl;
107
210
  private widthValueEl;
@@ -300,6 +403,10 @@ export declare class LayerControl implements IControl {
300
403
  * Open style editor for a layer
301
404
  */
302
405
  private openStyleEditor;
406
+ /**
407
+ * Create info panel for custom layers (style editing not supported)
408
+ */
409
+ private createCustomLayerInfoPanel;
303
410
  /**
304
411
  * Close style editor for a layer
305
412
  */
@@ -384,6 +491,8 @@ export declare interface LayerControlOptions {
384
491
  panelMaxHeight?: number;
385
492
  /** Whether to exclude drawn layers from drawing libraries like Geoman, Mapbox GL Draw, etc. (default: true) */
386
493
  excludeDrawnLayers?: boolean;
494
+ /** Custom layer adapters for non-MapLibre layers (e.g., deck.gl COG layers, Zarr layers) */
495
+ customLayerAdapters?: CustomLayerAdapter[];
387
496
  }
388
497
 
389
498
  /**
@@ -396,6 +505,10 @@ export declare interface LayerState {
396
505
  opacity: number;
397
506
  /** Display name for the layer */
398
507
  name: string;
508
+ /** Whether this is a custom (non-MapLibre) layer */
509
+ isCustomLayer?: boolean;
510
+ /** Custom layer type identifier (e.g., 'cog', 'zarr') */
511
+ customLayerType?: string;
399
512
  }
400
513
 
401
514
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "maplibre-gl-layer-control",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "A comprehensive layer control for MapLibre GL with advanced styling capabilities",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -91,6 +91,6 @@
91
91
  "vitest": "^2.1.0"
92
92
  },
93
93
  "dependencies": {
94
- "maplibre-gl-layer-control": "^0.2.0"
94
+ "maplibre-gl-layer-control": "^0.5.1"
95
95
  }
96
96
  }