maplibre-gl-layer-control 0.18.3 → 0.19.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.
- package/README.md +21 -0
- package/dist/{LayerControl-BVcYNnJ3.cjs → LayerControl-2Gi-t4dS.cjs} +165 -7
- package/dist/LayerControl-2Gi-t4dS.cjs.map +1 -0
- package/dist/{LayerControl-dS3dARlw.js → LayerControl-Ccyj0y-D.js} +165 -7
- package/dist/LayerControl-Ccyj0y-D.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 +78 -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-2Gi-t4dS.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-2Gi-t4dS.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-Ccyj0y-D.js";
|
|
3
3
|
function LayerControlReact({
|
|
4
4
|
map,
|
|
5
5
|
position = "top-right",
|
package/dist/types/index.d.ts
CHANGED
|
@@ -393,6 +393,14 @@ 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
|
+
/** setLayerState calls made before the layers were listed, applied once they are. */
|
|
401
|
+
private pendingLayerStates;
|
|
402
|
+
/** Panel order set through setLayerOrder, used to order layers with nothing on the map. */
|
|
403
|
+
private layerOrderHint;
|
|
396
404
|
private widthFrame;
|
|
397
405
|
private opacityInputEl;
|
|
398
406
|
private resizeHandleEls;
|
|
@@ -417,6 +425,13 @@ export declare class LayerControl implements IControl {
|
|
|
417
425
|
private backgroundPresetStorageKey;
|
|
418
426
|
private onBackgroundPresetsChange?;
|
|
419
427
|
constructor(options?: LayerControlOptions);
|
|
428
|
+
/**
|
|
429
|
+
* Whether basemap membership is decided by a known list of basemap layer IDs
|
|
430
|
+
* (the `basemapLayerIds` option, or the layers of `basemapStyleUrl`) rather
|
|
431
|
+
* than by heuristics. A fetched style only counts when it had layers; an
|
|
432
|
+
* explicit list counts even when empty.
|
|
433
|
+
*/
|
|
434
|
+
private hasBasemapLayerIds;
|
|
420
435
|
/**
|
|
421
436
|
* Called when the control is added to the map
|
|
422
437
|
*/
|
|
@@ -547,13 +562,63 @@ export declare class LayerControl implements IControl {
|
|
|
547
562
|
*/
|
|
548
563
|
private toggle;
|
|
549
564
|
/**
|
|
550
|
-
*
|
|
565
|
+
* Whether the panel is collapsed (closed). Before the control is added to a
|
|
566
|
+
* map this reflects the `collapsed` option.
|
|
567
|
+
* @returns True while the panel is closed
|
|
551
568
|
*/
|
|
552
|
-
|
|
569
|
+
isCollapsed(): boolean;
|
|
553
570
|
/**
|
|
554
|
-
*
|
|
571
|
+
* Expand (open) the panel. Before the control is added to a map this only
|
|
572
|
+
* records the state, and the panel opens when it is built.
|
|
573
|
+
*/
|
|
574
|
+
expand(): void;
|
|
575
|
+
/**
|
|
576
|
+
* Collapse (close) the panel.
|
|
577
|
+
*/
|
|
578
|
+
collapse(): void;
|
|
579
|
+
/**
|
|
580
|
+
* Update a layer row's visibility, opacity and name in place, without
|
|
581
|
+
* touching the map or firing any callback. Use it to mirror changes made
|
|
582
|
+
* outside the control (for example by an application store that owns layer
|
|
583
|
+
* state) into an already-built panel without rebuilding it.
|
|
584
|
+
*
|
|
585
|
+
* Only layers the control already lists are updated, with one exception:
|
|
586
|
+
* `"Background"` adds the Background row when the control has none (a style
|
|
587
|
+
* whose basemap lives in style imports has no root basemap layers to detect,
|
|
588
|
+
* so the control would otherwise show no Background row).
|
|
589
|
+
*
|
|
590
|
+
* Until the control has listed the map's layers (during `onAdd`, and while a
|
|
591
|
+
* `basemapStyleUrl` fetch is in flight) the update is queued and applied
|
|
592
|
+
* once they are listed, since seeding state earlier would stop the control
|
|
593
|
+
* from detecting layers on its own.
|
|
594
|
+
*
|
|
595
|
+
* @param layerId The layer ID, or `"Background"` for the basemap row
|
|
596
|
+
* @param state The fields to change; omitted fields keep their value
|
|
597
|
+
* @returns True if a layer state was updated, created or queued; false
|
|
598
|
+
* before the control is added to a map or for a layer it does not list
|
|
555
599
|
*/
|
|
556
|
-
|
|
600
|
+
setLayerState(layerId: string, state: Partial<Pick<LayerState, "visible" | "opacity" | "name">>): boolean;
|
|
601
|
+
/**
|
|
602
|
+
* Mark the map's layers as listed and apply setLayerState calls queued
|
|
603
|
+
* before then.
|
|
604
|
+
*/
|
|
605
|
+
private finishListing;
|
|
606
|
+
/**
|
|
607
|
+
* Set the order the panel lists layers in, then redraw the rows.
|
|
608
|
+
*
|
|
609
|
+
* Layers whose native MapLibre layers are on the map are always listed in
|
|
610
|
+
* map stacking order; this order applies to the rest (custom-adapter layers
|
|
611
|
+
* with nothing on the map yet, such as hidden ones). Use it to put the panel
|
|
612
|
+
* back after an application refused a drag or context-menu move, since the
|
|
613
|
+
* control has already moved the row by then. Layers not listed keep their
|
|
614
|
+
* relative order after the listed ones, and Background stays at the bottom.
|
|
615
|
+
* A hidden custom layer whose adapter has other layers on the map keeps its
|
|
616
|
+
* slot beside them in that adapter's list, since the adapter is the source of
|
|
617
|
+
* truth for where it sits; this order breaks the remaining ties.
|
|
618
|
+
*
|
|
619
|
+
* @param layerIds Layer IDs, top of the panel first
|
|
620
|
+
*/
|
|
621
|
+
setLayerOrder(layerIds: readonly string[]): void;
|
|
557
622
|
/**
|
|
558
623
|
* Build layer items (called initially and when layers change)
|
|
559
624
|
*/
|
|
@@ -1170,6 +1235,15 @@ export declare interface LayerControlOptions {
|
|
|
1170
1235
|
* and user-added layers.
|
|
1171
1236
|
*/
|
|
1172
1237
|
basemapStyleUrl?: string;
|
|
1238
|
+
/**
|
|
1239
|
+
* IDs of the layers that make up the basemap, for applications that already
|
|
1240
|
+
* know them (or have no fetchable style URL, such as a style built in code).
|
|
1241
|
+
* Those layers are grouped under "Background" and every other layer is
|
|
1242
|
+
* treated as user-added. Takes precedence over `basemapStyleUrl` (nothing is
|
|
1243
|
+
* fetched), and an empty array is honoured as "no basemap layers" rather than
|
|
1244
|
+
* falling back to heuristic detection.
|
|
1245
|
+
*/
|
|
1246
|
+
basemapLayerIds?: string[];
|
|
1173
1247
|
/** Whether to enable context menu (right-click) on layers (default: true) */
|
|
1174
1248
|
enableContextMenu?: boolean;
|
|
1175
1249
|
/** 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) */
|