maplibre-gl-layer-control 0.17.1 → 0.17.2

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.
package/README.md CHANGED
@@ -179,6 +179,8 @@ function MapComponent() {
179
179
  | `enableBackgroundPresets` | `boolean` | `true` | Show the "Saved configurations" controls in the Background Layers panel |
180
180
  | `backgroundPresetStorageKey` | `string` | `'maplibre-layer-control:background-presets'` | `localStorage` key under which background visibility presets are stored |
181
181
  | `onBackgroundPresetsChange` | `(presets: BackgroundPresets) => void` | `undefined` | Called whenever the saved preset set changes (created or deleted); applying a preset does not change the set, so it does not fire |
182
+ | `onBackgroundVisibilityChange` | `(visible: boolean) => void` | `undefined` | Called when the Background (basemap) group is toggled via the checkbox; mirror it into your own store to keep external basemap UI in sync |
183
+ | `onBackgroundOpacityChange` | `(opacity: number) => void` | `undefined` | Called when the Background (basemap) group opacity slider changes; mirror it into your own store to keep external basemap UI in sync |
182
184
 
183
185
  ### LayerState
184
186
 
package/dist/index.cjs CHANGED
@@ -724,6 +724,8 @@ class LayerControl {
724
724
  __publicField(this, "onLayerRename");
725
725
  __publicField(this, "onLayerReorder");
726
726
  __publicField(this, "onLayerRemove");
727
+ __publicField(this, "onBackgroundVisibilityChange");
728
+ __publicField(this, "onBackgroundOpacityChange");
727
729
  // Background-layer visibility presets
728
730
  __publicField(this, "enableBackgroundPresets");
729
731
  __publicField(this, "backgroundPresetStorageKey");
@@ -744,6 +746,8 @@ class LayerControl {
744
746
  this.onLayerRename = options.onLayerRename;
745
747
  this.onLayerReorder = options.onLayerReorder;
746
748
  this.onLayerRemove = options.onLayerRemove;
749
+ this.onBackgroundVisibilityChange = options.onBackgroundVisibilityChange;
750
+ this.onBackgroundOpacityChange = options.onBackgroundOpacityChange;
747
751
  this.enableBackgroundPresets = options.enableBackgroundPresets !== false;
748
752
  this.backgroundPresetStorageKey = options.backgroundPresetStorageKey || "maplibre-layer-control:background-presets";
749
753
  this.onBackgroundPresetsChange = options.onBackgroundPresetsChange;
@@ -1906,6 +1910,7 @@ class LayerControl {
1906
1910
  * Toggle visibility for all background layers (basemap layers)
1907
1911
  */
1908
1912
  toggleBackgroundVisibility(visible) {
1913
+ var _a;
1909
1914
  if (this.state.layerStates["Background"]) {
1910
1915
  this.state.layerStates["Background"].visible = visible;
1911
1916
  }
@@ -1933,11 +1938,13 @@ class LayerControl {
1933
1938
  });
1934
1939
  }
1935
1940
  }
1941
+ (_a = this.onBackgroundVisibilityChange) == null ? void 0 : _a.call(this, visible);
1936
1942
  }
1937
1943
  /**
1938
1944
  * Change opacity for all background layers (basemap layers)
1939
1945
  */
1940
1946
  changeBackgroundOpacity(opacity) {
1947
+ var _a;
1941
1948
  if (this.state.layerStates["Background"]) {
1942
1949
  this.state.layerStates["Background"].opacity = opacity;
1943
1950
  }
@@ -1950,6 +1957,7 @@ class LayerControl {
1950
1957
  }
1951
1958
  }
1952
1959
  });
1960
+ (_a = this.onBackgroundOpacityChange) == null ? void 0 : _a.call(this, opacity);
1953
1961
  }
1954
1962
  // ===== Background Legend Methods =====
1955
1963
  /**