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