maplibre-gl-layer-control 0.18.3 → 0.19.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.
- package/README.md +21 -0
- package/dist/{LayerControl-BVcYNnJ3.cjs → LayerControl-BxSfUXK6.cjs} +141 -7
- package/dist/LayerControl-BxSfUXK6.cjs.map +1 -0
- package/dist/{LayerControl-dS3dARlw.js → LayerControl-CvH3r0T2.js} +141 -7
- package/dist/LayerControl-CvH3r0T2.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/react.cjs +1 -1
- package/dist/react.mjs +1 -1
- package/dist/types/index.d.ts +68 -4
- package/dist/types/react.d.ts +9 -0
- package/package.json +1 -1
- package/dist/LayerControl-BVcYNnJ3.cjs.map +0 -1
- package/dist/LayerControl-dS3dARlw.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const LayerControl = require("./LayerControl-
|
|
3
|
+
const LayerControl = require("./LayerControl-BxSfUXK6.cjs");
|
|
4
4
|
exports.CustomLayerRegistry = LayerControl.CustomLayerRegistry;
|
|
5
5
|
exports.LayerControl = LayerControl.LayerControl;
|
|
6
6
|
exports.clamp = LayerControl.clamp;
|
package/dist/index.mjs
CHANGED
package/dist/react.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const react = require("react");
|
|
4
|
-
const LayerControl = require("./LayerControl-
|
|
4
|
+
const LayerControl = require("./LayerControl-BxSfUXK6.cjs");
|
|
5
5
|
function LayerControlReact({
|
|
6
6
|
map,
|
|
7
7
|
position = "top-right",
|
package/dist/react.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useRef, useEffect, useState, useCallback } from "react";
|
|
2
|
-
import { L as LayerControl, g as getLayerType, s as setLayerOpacity, p as cacheOriginalLayerStyle, q as restoreOriginalStyle, c as clamp, a as getLayerOpacity } from "./LayerControl-
|
|
2
|
+
import { L as LayerControl, g as getLayerType, s as setLayerOpacity, p as cacheOriginalLayerStyle, q as restoreOriginalStyle, c as clamp, a as getLayerOpacity } from "./LayerControl-CvH3r0T2.js";
|
|
3
3
|
function LayerControlReact({
|
|
4
4
|
map,
|
|
5
5
|
position = "top-right",
|
package/dist/types/index.d.ts
CHANGED
|
@@ -393,6 +393,12 @@ export declare class LayerControl implements IControl {
|
|
|
393
393
|
private groupStructureKey;
|
|
394
394
|
private basemapStyleUrl;
|
|
395
395
|
private basemapLayerIds;
|
|
396
|
+
/** True when `basemapLayerIds` came from the option, which is authoritative even when empty. */
|
|
397
|
+
private basemapLayerIdsProvided;
|
|
398
|
+
/** Set once onAdd has listed the map's layers (after any basemapStyleUrl fetch). */
|
|
399
|
+
private layersListed;
|
|
400
|
+
/** Panel order set through setLayerOrder, used to order layers with nothing on the map. */
|
|
401
|
+
private layerOrderHint;
|
|
396
402
|
private widthFrame;
|
|
397
403
|
private opacityInputEl;
|
|
398
404
|
private resizeHandleEls;
|
|
@@ -417,6 +423,13 @@ export declare class LayerControl implements IControl {
|
|
|
417
423
|
private backgroundPresetStorageKey;
|
|
418
424
|
private onBackgroundPresetsChange?;
|
|
419
425
|
constructor(options?: LayerControlOptions);
|
|
426
|
+
/**
|
|
427
|
+
* Whether basemap membership is decided by a known list of basemap layer IDs
|
|
428
|
+
* (the `basemapLayerIds` option, or the layers of `basemapStyleUrl`) rather
|
|
429
|
+
* than by heuristics. A fetched style only counts when it had layers; an
|
|
430
|
+
* explicit list counts even when empty.
|
|
431
|
+
*/
|
|
432
|
+
private hasBasemapLayerIds;
|
|
420
433
|
/**
|
|
421
434
|
* Called when the control is added to the map
|
|
422
435
|
*/
|
|
@@ -547,13 +560,55 @@ export declare class LayerControl implements IControl {
|
|
|
547
560
|
*/
|
|
548
561
|
private toggle;
|
|
549
562
|
/**
|
|
550
|
-
*
|
|
563
|
+
* Whether the panel is collapsed (closed). Before the control is added to a
|
|
564
|
+
* map this reflects the `collapsed` option.
|
|
565
|
+
* @returns True while the panel is closed
|
|
566
|
+
*/
|
|
567
|
+
isCollapsed(): boolean;
|
|
568
|
+
/**
|
|
569
|
+
* Expand (open) the panel. Before the control is added to a map this only
|
|
570
|
+
* records the state, and the panel opens when it is built.
|
|
571
|
+
*/
|
|
572
|
+
expand(): void;
|
|
573
|
+
/**
|
|
574
|
+
* Collapse (close) the panel.
|
|
575
|
+
*/
|
|
576
|
+
collapse(): void;
|
|
577
|
+
/**
|
|
578
|
+
* Update a layer row's visibility, opacity and name in place, without
|
|
579
|
+
* touching the map or firing any callback. Use it to mirror changes made
|
|
580
|
+
* outside the control (for example by an application store that owns layer
|
|
581
|
+
* state) into an already-built panel without rebuilding it.
|
|
582
|
+
*
|
|
583
|
+
* Only layers the control already lists are updated, with one exception:
|
|
584
|
+
* `"Background"` adds the Background row when the control has none (a style
|
|
585
|
+
* whose basemap lives in style imports has no root basemap layers to detect,
|
|
586
|
+
* so the control would otherwise show no Background row). It returns false
|
|
587
|
+
* until the control has listed the map's layers (after `onAdd`, and after a
|
|
588
|
+
* `basemapStyleUrl` fetch), since seeding state earlier would stop the
|
|
589
|
+
* control from detecting layers on its own.
|
|
590
|
+
*
|
|
591
|
+
* @param layerId The layer ID, or `"Background"` for the basemap row
|
|
592
|
+
* @param state The fields to change; omitted fields keep their value
|
|
593
|
+
* @returns True if a layer state was updated or created
|
|
551
594
|
*/
|
|
552
|
-
|
|
595
|
+
setLayerState(layerId: string, state: Partial<Pick<LayerState, "visible" | "opacity" | "name">>): boolean;
|
|
553
596
|
/**
|
|
554
|
-
*
|
|
597
|
+
* Set the order the panel lists layers in, then redraw the rows.
|
|
598
|
+
*
|
|
599
|
+
* Layers whose native MapLibre layers are on the map are always listed in
|
|
600
|
+
* map stacking order; this order applies to the rest (custom-adapter layers
|
|
601
|
+
* with nothing on the map yet, such as hidden ones). Use it to put the panel
|
|
602
|
+
* back after an application refused a drag or context-menu move, since the
|
|
603
|
+
* control has already moved the row by then. Layers not listed keep their
|
|
604
|
+
* relative order after the listed ones, and Background stays at the bottom.
|
|
605
|
+
* A hidden custom layer whose adapter has other layers on the map keeps its
|
|
606
|
+
* slot beside them in that adapter's list, since the adapter is the source of
|
|
607
|
+
* truth for where it sits; this order breaks the remaining ties.
|
|
608
|
+
*
|
|
609
|
+
* @param layerIds Layer IDs, top of the panel first
|
|
555
610
|
*/
|
|
556
|
-
|
|
611
|
+
setLayerOrder(layerIds: readonly string[]): void;
|
|
557
612
|
/**
|
|
558
613
|
* Build layer items (called initially and when layers change)
|
|
559
614
|
*/
|
|
@@ -1170,6 +1225,15 @@ export declare interface LayerControlOptions {
|
|
|
1170
1225
|
* and user-added layers.
|
|
1171
1226
|
*/
|
|
1172
1227
|
basemapStyleUrl?: string;
|
|
1228
|
+
/**
|
|
1229
|
+
* IDs of the layers that make up the basemap, for applications that already
|
|
1230
|
+
* know them (or have no fetchable style URL, such as a style built in code).
|
|
1231
|
+
* Those layers are grouped under "Background" and every other layer is
|
|
1232
|
+
* treated as user-added. Takes precedence over `basemapStyleUrl` (nothing is
|
|
1233
|
+
* fetched), and an empty array is honoured as "no basemap layers" rather than
|
|
1234
|
+
* falling back to heuristic detection.
|
|
1235
|
+
*/
|
|
1236
|
+
basemapLayerIds?: string[];
|
|
1173
1237
|
/** Whether to enable context menu (right-click) on layers (default: true) */
|
|
1174
1238
|
enableContextMenu?: boolean;
|
|
1175
1239
|
/** Whether to enable drag-and-drop reordering of layers (default: true) */
|
package/dist/types/react.d.ts
CHANGED
|
@@ -205,6 +205,15 @@ export declare interface LayerControlOptions {
|
|
|
205
205
|
* and user-added layers.
|
|
206
206
|
*/
|
|
207
207
|
basemapStyleUrl?: string;
|
|
208
|
+
/**
|
|
209
|
+
* IDs of the layers that make up the basemap, for applications that already
|
|
210
|
+
* know them (or have no fetchable style URL, such as a style built in code).
|
|
211
|
+
* Those layers are grouped under "Background" and every other layer is
|
|
212
|
+
* treated as user-added. Takes precedence over `basemapStyleUrl` (nothing is
|
|
213
|
+
* fetched), and an empty array is honoured as "no basemap layers" rather than
|
|
214
|
+
* falling back to heuristic detection.
|
|
215
|
+
*/
|
|
216
|
+
basemapLayerIds?: string[];
|
|
208
217
|
/** Whether to enable context menu (right-click) on layers (default: true) */
|
|
209
218
|
enableContextMenu?: boolean;
|
|
210
219
|
/** Whether to enable drag-and-drop reordering of layers (default: true) */
|