maplibre-gl-layer-control-tidop 0.0.21 → 0.0.22
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/dist/index.cjs +3 -43
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +3 -43
- package/dist/index.mjs.map +1 -1
- package/dist/types/index.d.ts +0 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1085,7 +1085,7 @@ class LayerControl {
|
|
|
1085
1085
|
let name = layerId.replace(/^(layer[-_]?|gl[-_]?)/, "");
|
|
1086
1086
|
name = name.replace(/[-_]/g, " ");
|
|
1087
1087
|
name = name.replace(/\b\w/g, (char) => char.toUpperCase());
|
|
1088
|
-
return layerId;
|
|
1088
|
+
return name || layerId;
|
|
1089
1089
|
}
|
|
1090
1090
|
/**
|
|
1091
1091
|
* Check if a layer ID belongs to a drawing library (Geoman, Mapbox GL Draw, etc.)
|
|
@@ -1270,11 +1270,6 @@ class LayerControl {
|
|
|
1270
1270
|
title.className = "layer-control-panel-title";
|
|
1271
1271
|
title.textContent = "Layers";
|
|
1272
1272
|
header.appendChild(title);
|
|
1273
|
-
const input = document.createElement("input");
|
|
1274
|
-
input.id = "layer-control-panel-layer-id";
|
|
1275
|
-
input.className = "layer-control-panel-layer-id";
|
|
1276
|
-
input.value = "";
|
|
1277
|
-
header.appendChild(input);
|
|
1278
1273
|
const widthControl = this.createWidthControl();
|
|
1279
1274
|
header.appendChild(widthControl);
|
|
1280
1275
|
return header;
|
|
@@ -1629,10 +1624,6 @@ class LayerControl {
|
|
|
1629
1624
|
}
|
|
1630
1625
|
}
|
|
1631
1626
|
}
|
|
1632
|
-
const tidopButton = this.createTidopButton(layerId);
|
|
1633
|
-
if (tidopButton) {
|
|
1634
|
-
row.appendChild(tidopButton);
|
|
1635
|
-
}
|
|
1636
1627
|
item.appendChild(row);
|
|
1637
1628
|
if (this.enableContextMenu && layerId !== "Background") {
|
|
1638
1629
|
row.addEventListener("contextmenu", (e) => {
|
|
@@ -1641,7 +1632,7 @@ class LayerControl {
|
|
|
1641
1632
|
this.showContextMenu(layerId, e.clientX, e.clientY);
|
|
1642
1633
|
});
|
|
1643
1634
|
}
|
|
1644
|
-
this.panel.
|
|
1635
|
+
this.panel.appendChild(item);
|
|
1645
1636
|
}
|
|
1646
1637
|
/**
|
|
1647
1638
|
* Create a symbol element for a layer
|
|
@@ -2105,46 +2096,17 @@ class LayerControl {
|
|
|
2105
2096
|
});
|
|
2106
2097
|
return button;
|
|
2107
2098
|
}
|
|
2108
|
-
createTidopButton(layerId) {
|
|
2109
|
-
if (layerId === "Background") {
|
|
2110
|
-
return null;
|
|
2111
|
-
}
|
|
2112
|
-
const layerState = this.state.layerStates[layerId];
|
|
2113
|
-
const isCustomLayer = (layerState == null ? void 0 : layerState.isCustomLayer) === true;
|
|
2114
|
-
const button = document.createElement("button");
|
|
2115
|
-
button.className = "layer-control-style-button layer-control-tidop-button-" + layerId;
|
|
2116
|
-
button.innerHTML = "⚙";
|
|
2117
|
-
if (isCustomLayer) {
|
|
2118
|
-
button.title = "Layer info (style editing not available)";
|
|
2119
|
-
button.setAttribute("aria-label", `Layer info for ${layerId}`);
|
|
2120
|
-
} else {
|
|
2121
|
-
button.title = "Edit layer style";
|
|
2122
|
-
button.setAttribute("aria-label", `Edit style for ${layerId}`);
|
|
2123
|
-
}
|
|
2124
|
-
button.addEventListener("click", (e) => {
|
|
2125
|
-
this.toggleStyleEditor(layerId);
|
|
2126
|
-
console.log(e);
|
|
2127
|
-
});
|
|
2128
|
-
return button;
|
|
2129
|
-
}
|
|
2130
2099
|
/**
|
|
2131
2100
|
* Toggle style editor for a layer
|
|
2132
2101
|
*/
|
|
2133
2102
|
toggleStyleEditor(layerId) {
|
|
2134
2103
|
if (this.state.activeStyleEditor === layerId) {
|
|
2135
|
-
var el = this.panel.querySelector("#layer-control-panel-layer-id");
|
|
2136
|
-
console.log(el);
|
|
2137
|
-
if (el)
|
|
2138
|
-
el.value = "";
|
|
2139
2104
|
this.closeStyleEditor(layerId);
|
|
2140
2105
|
return;
|
|
2141
2106
|
}
|
|
2142
2107
|
if (this.state.activeStyleEditor) {
|
|
2143
2108
|
this.closeStyleEditor(this.state.activeStyleEditor);
|
|
2144
2109
|
}
|
|
2145
|
-
var el = this.panel.querySelector("#layer-control-panel-layer-id");
|
|
2146
|
-
if (el)
|
|
2147
|
-
el.value = layerId;
|
|
2148
2110
|
this.openStyleEditor(layerId);
|
|
2149
2111
|
}
|
|
2150
2112
|
/**
|
|
@@ -3491,9 +3453,7 @@ class LayerControl {
|
|
|
3491
3453
|
uiLayerIds.push(layerId);
|
|
3492
3454
|
}
|
|
3493
3455
|
});
|
|
3494
|
-
|
|
3495
|
-
const reversedIds = [...uiLayerIds];
|
|
3496
|
-
console.log(reversedIds);
|
|
3456
|
+
const reversedIds = [...uiLayerIds].reverse();
|
|
3497
3457
|
const style = this.map.getStyle();
|
|
3498
3458
|
const mapLibreLayerIds = new Set(((_a = style == null ? void 0 : style.layers) == null ? void 0 : _a.map((l) => l.id)) || []);
|
|
3499
3459
|
for (let i = 0; i < reversedIds.length; i++) {
|