maplibre-gl-layer-control 0.4.0 → 0.5.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.
@@ -227,6 +227,22 @@
227
227
  white-space: nowrap;
228
228
  }
229
229
 
230
+ /* Layer symbol/icon */
231
+ .layer-control-symbol {
232
+ display: inline-flex;
233
+ align-items: center;
234
+ justify-content: center;
235
+ width: 18px;
236
+ height: 18px;
237
+ flex-shrink: 0;
238
+ }
239
+
240
+ .layer-control-symbol svg {
241
+ width: 16px;
242
+ height: 16px;
243
+ display: block;
244
+ }
245
+
230
246
  .layer-control-opacity {
231
247
  flex: 0 0 140px;
232
248
  height: 16px;
@@ -808,6 +824,22 @@
808
824
  flex-shrink: 0;
809
825
  }
810
826
 
827
+ /* Layer symbol in background legend */
828
+ .background-legend-layer-symbol {
829
+ display: inline-flex;
830
+ align-items: center;
831
+ justify-content: center;
832
+ width: 14px;
833
+ height: 14px;
834
+ flex-shrink: 0;
835
+ }
836
+
837
+ .background-legend-layer-symbol svg {
838
+ width: 14px;
839
+ height: 14px;
840
+ display: block;
841
+ }
842
+
811
843
  .background-legend-layer-name {
812
844
  flex: 1;
813
845
  font-size: 11px;
@@ -1,4 +1,5 @@
1
1
  import { IControl } from 'maplibre-gl';
2
+ import { LayerSpecification } from 'maplibre-gl';
2
3
  import { Map as Map_2 } from 'maplibre-gl';
3
4
 
4
5
  /**
@@ -10,6 +11,30 @@ import { Map as Map_2 } from 'maplibre-gl';
10
11
  */
11
12
  export declare function clamp(value: number, min: number, max: number): number;
12
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
+ * Darken a hex color by a given amount
32
+ * @param hexColor The hex color to darken (e.g., '#ff0000')
33
+ * @param amount Amount to darken (0-1, where 1 is fully black)
34
+ * @returns The darkened hex color
35
+ */
36
+ export declare function darkenColor(hexColor: string, amount: number): string;
37
+
13
38
  /**
14
39
  * Format a numeric value based on the step size
15
40
  * @param value Numeric value to format
@@ -18,6 +43,22 @@ export declare function clamp(value: number, min: number, max: number): number;
18
43
  */
19
44
  export declare function formatNumericValue(value: number, step: number): string;
20
45
 
46
+ /**
47
+ * Get the primary color from a layer's paint properties
48
+ * @param map The MapLibre map instance
49
+ * @param layerId The layer ID
50
+ * @param layerType The layer type
51
+ * @returns The normalized hex color, or null if not found
52
+ */
53
+ export declare function getLayerColor(map: Map_2, layerId: string, layerType: string): string | null;
54
+
55
+ /**
56
+ * Get the primary color directly from a layer specification
57
+ * @param layer The layer specification
58
+ * @returns The normalized hex color, or null if not found
59
+ */
60
+ export declare function getLayerColorFromSpec(layer: LayerSpecification): string | null;
61
+
21
62
  /**
22
63
  * Get the current opacity value for a layer
23
64
  * @param map MapLibre map instance
@@ -56,8 +97,11 @@ export declare class LayerControl implements IControl {
56
97
  private styleEditors;
57
98
  private minPanelWidth;
58
99
  private maxPanelWidth;
100
+ private maxPanelHeight;
59
101
  private showStyleEditor;
60
102
  private showOpacitySlider;
103
+ private showLayerSymbol;
104
+ private excludeDrawnLayers;
61
105
  private widthSliderEl;
62
106
  private widthThumbEl;
63
107
  private widthValueEl;
@@ -88,6 +132,12 @@ export declare class LayerControl implements IControl {
88
132
  * Generate a friendly display name from a layer ID
89
133
  */
90
134
  private generateFriendlyName;
135
+ /**
136
+ * Check if a layer ID belongs to a drawing library (Geoman, Mapbox GL Draw, etc.)
137
+ * @param layerId The layer ID to check
138
+ * @returns true if the layer is from a drawing library
139
+ */
140
+ private isDrawnLayer;
91
141
  /**
92
142
  * Create the main container element
93
143
  */
@@ -160,6 +210,24 @@ export declare class LayerControl implements IControl {
160
210
  * Add a single layer item to the panel
161
211
  */
162
212
  private addLayerItem;
213
+ /**
214
+ * Create a symbol element for a layer
215
+ * @param layerId The layer ID
216
+ * @returns The symbol HTML element, or null if layer not found
217
+ */
218
+ private createLayerSymbol;
219
+ /**
220
+ * Create a symbol element for a background layer
221
+ * @param layer The layer specification
222
+ * @returns The symbol HTML element
223
+ */
224
+ private createBackgroundLayerSymbol;
225
+ /**
226
+ * Create a symbol element for the Background layer group
227
+ * Shows a stacked layers icon to represent multiple background layers
228
+ * @returns The symbol HTML element
229
+ */
230
+ private createBackgroundGroupSymbol;
163
231
  /**
164
232
  * Toggle layer visibility
165
233
  */
@@ -310,6 +378,12 @@ export declare interface LayerControlOptions {
310
378
  showStyleEditor?: boolean;
311
379
  /** Whether to show the opacity slider for layers (default: true) */
312
380
  showOpacitySlider?: boolean;
381
+ /** Whether to show layer type symbols/icons next to layer names (default: true) */
382
+ showLayerSymbol?: boolean;
383
+ /** Maximum panel height in pixels (default: 600). When content exceeds this height, the panel becomes scrollable. */
384
+ panelMaxHeight?: number;
385
+ /** Whether to exclude drawn layers from drawing libraries like Geoman, Mapbox GL Draw, etc. (default: true) */
386
+ excludeDrawnLayers?: boolean;
313
387
  }
314
388
 
315
389
  /**
@@ -392,4 +466,14 @@ export declare interface StyleControlConfig {
392
466
  defaultValue?: any;
393
467
  }
394
468
 
469
+ /**
470
+ * Symbol generation options
471
+ */
472
+ export declare interface SymbolOptions {
473
+ /** Symbol size in pixels (default: 16) */
474
+ size?: number;
475
+ /** Stroke width for line symbols (default: 2) */
476
+ strokeWidth?: number;
477
+ }
478
+
395
479
  export { }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "maplibre-gl-layer-control",
3
- "version": "0.4.0",
3
+ "version": "0.5.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",