maplibre-gl-components 0.22.6 → 0.22.7
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/{ControlGrid-BX81K4Oc.js → ControlGrid-B-8T7XE1.js} +30 -25
- package/dist/{ControlGrid-3cC2XMb4.cjs → ControlGrid-C3gI7CEH.cjs} +8 -8
- package/dist/{DuckDBConverter-OdEbbaG0.cjs → DuckDBConverter-A5JA4Bbh.cjs} +1 -1
- package/dist/{ShapefileConverter-Djc69lcP.cjs → ShapefileConverter-BjjE66F1.cjs} +1 -1
- package/dist/{geotiff-H7UXf-4Q.cjs → geotiff-NQLiOW50.cjs} +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{lerc-Cq7Syri9.cjs → lerc-X7dkbhg0.cjs} +1 -1
- package/dist/{maplibre-geoman.es-BiSZ4hUw.cjs → maplibre-geoman.es-BflhwRD2.cjs} +1 -1
- package/dist/maplibre-gl-components.css +1 -1
- package/dist/react.cjs +1 -1
- package/dist/react.mjs +1 -1
- package/dist/types/lib/core/MeasureControl.d.ts +10 -0
- package/dist/types/lib/core/MeasureControl.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -5115,6 +5115,7 @@ var xO = class {
|
|
|
5115
5115
|
_boundClickHandler;
|
|
5116
5116
|
_boundMoveHandler;
|
|
5117
5117
|
_boundDblClickHandler;
|
|
5118
|
+
_boundContextMenuHandler;
|
|
5118
5119
|
_boundKeyHandler;
|
|
5119
5120
|
_markers = [];
|
|
5120
5121
|
constructor(e) {
|
|
@@ -5213,7 +5214,7 @@ var xO = class {
|
|
|
5213
5214
|
<div class="segment-label">Segments</div>
|
|
5214
5215
|
<div class="segment-list"></div>
|
|
5215
5216
|
</div>
|
|
5216
|
-
`, this._resultValueEl = a.querySelector(".result-value"), this._resultUnitEl = a.querySelector(".result-unit"), this._segmentListEl = a.querySelector(".segment-list"), n.appendChild(a), this._instructionsEl = document.createElement("div"), this._instructionsEl.className = "measure-instructions", this._instructionsEl.textContent = "Click
|
|
5217
|
+
`, this._resultValueEl = a.querySelector(".result-value"), this._resultUnitEl = a.querySelector(".result-unit"), this._segmentListEl = a.querySelector(".segment-list"), n.appendChild(a), this._instructionsEl = document.createElement("div"), this._instructionsEl.className = "measure-instructions", this._instructionsEl.textContent = "Click the map to add points. Double-click or right-click to finish.", n.appendChild(this._instructionsEl), this._measurementsListEl = document.createElement("div"), this._measurementsListEl.className = "measurements-list", this._measurementsListEl.style.display = "none", n.appendChild(this._measurementsListEl);
|
|
5217
5218
|
const o = document.createElement("div");
|
|
5218
5219
|
return o.className = "measure-actions", o.innerHTML = `
|
|
5219
5220
|
<button type="button" class="action-btn primary start-btn">
|
|
@@ -5249,20 +5250,20 @@ var xO = class {
|
|
|
5249
5250
|
this._state.collapsed ? this.expand() : this.collapse();
|
|
5250
5251
|
}
|
|
5251
5252
|
_showPanel() {
|
|
5252
|
-
!this._panel && this._container && (this._panel = this._createPanel(), this._container.appendChild(this._panel)), this._button?.classList.add("active");
|
|
5253
|
+
!this._panel && this._container && (this._panel = this._createPanel(), this._container.appendChild(this._panel)), this._button?.classList.add("active"), this._state.isDrawing || this._startDrawing();
|
|
5253
5254
|
}
|
|
5254
5255
|
_hidePanel() {
|
|
5255
5256
|
this._stopDrawing(), this._panel?.remove(), this._panel = void 0, this._button?.classList.remove("active");
|
|
5256
5257
|
}
|
|
5257
5258
|
_setMode(e) {
|
|
5258
|
-
|
|
5259
|
-
this.
|
|
5260
|
-
|
|
5259
|
+
const t = e !== this._state.mode;
|
|
5260
|
+
this._state.mode = e, this._panel?.querySelectorAll(".mode-btn").forEach((s) => {
|
|
5261
|
+
s.classList.toggle("active", s.dataset.mode === e);
|
|
5261
5262
|
});
|
|
5262
|
-
const
|
|
5263
|
-
|
|
5264
|
-
const
|
|
5265
|
-
|
|
5263
|
+
const n = this._panel?.querySelector(".measure-unit select");
|
|
5264
|
+
n && this._updateUnitOptions(n);
|
|
5265
|
+
const i = this._panel?.querySelector(".result-label");
|
|
5266
|
+
i && (i.textContent = e === "distance" ? "Total Distance" : "Total Area"), t && this._emit("modechange"), this._panel && (this._state.isDrawing ? (this._updateMeasurement(), this._updateMapGeometry()) : this._startDrawing());
|
|
5266
5267
|
}
|
|
5267
5268
|
_setupMapSources() {
|
|
5268
5269
|
this._map && (this._map.addSource(this._sourceId, {
|
|
@@ -5300,15 +5301,17 @@ var xO = class {
|
|
|
5300
5301
|
const e = this._panel?.querySelector(".start-btn span");
|
|
5301
5302
|
e && (e.textContent = "Finish");
|
|
5302
5303
|
const t = this._panel?.querySelector(".measure-result");
|
|
5303
|
-
t && (t.style.display = "block"), this._instructionsEl && (this._instructionsEl.textContent = this._state.mode === "distance" ? "Click to add points. Double-click or
|
|
5304
|
+
t && (t.style.display = "block"), this._updateResult(), this._instructionsEl && (this._instructionsEl.textContent = this._state.mode === "distance" ? "Click to add points. Double-click, right-click, or Enter to finish." : "Click to add vertices. Double-click, right-click, or Enter to close the polygon."), this._boundClickHandler = (n) => this._handleClick(n), this._boundMoveHandler = (n) => this._handleMouseMove(n), this._boundDblClickHandler = (n) => {
|
|
5305
|
+
n.preventDefault(), this._finishOnDoubleClick();
|
|
5306
|
+
}, this._boundContextMenuHandler = (n) => {
|
|
5304
5307
|
n.preventDefault(), this._finishDrawing();
|
|
5305
5308
|
}, this._boundKeyHandler = (n) => {
|
|
5306
5309
|
n.key === "Enter" ? this._finishDrawing() : n.key === "Escape" && this._cancelDrawing();
|
|
5307
|
-
}, this._map.on("click", this._boundClickHandler), this._map.on("mousemove", this._boundMoveHandler), this._map.on("dblclick", this._boundDblClickHandler), document.addEventListener("keydown", this._boundKeyHandler), this._map.getCanvas().style.cursor = "crosshair", this._emit("drawstart");
|
|
5310
|
+
}, this._map.on("click", this._boundClickHandler), this._map.on("mousemove", this._boundMoveHandler), this._map.on("dblclick", this._boundDblClickHandler), this._map.on("contextmenu", this._boundContextMenuHandler), document.addEventListener("keydown", this._boundKeyHandler), this._map.getCanvas().style.cursor = "crosshair", this._emit("drawstart");
|
|
5308
5311
|
}
|
|
5309
5312
|
_stopDrawing() {
|
|
5310
5313
|
if (!this._map) return;
|
|
5311
|
-
this._boundClickHandler && this._map.off("click", this._boundClickHandler), this._boundMoveHandler && this._map.off("mousemove", this._boundMoveHandler), this._boundDblClickHandler && this._map.off("dblclick", this._boundDblClickHandler), this._boundKeyHandler && document.removeEventListener("keydown", this._boundKeyHandler), this._map.getCanvas().style.cursor = "", this._state.isDrawing = !1;
|
|
5314
|
+
this._boundClickHandler && this._map.off("click", this._boundClickHandler), this._boundMoveHandler && this._map.off("mousemove", this._boundMoveHandler), this._boundDblClickHandler && this._map.off("dblclick", this._boundDblClickHandler), this._boundContextMenuHandler && this._map.off("contextmenu", this._boundContextMenuHandler), this._boundKeyHandler && document.removeEventListener("keydown", this._boundKeyHandler), this._map.getCanvas().style.cursor = "", this._state.isDrawing = !1;
|
|
5312
5315
|
const e = this._panel?.querySelector(".start-btn span");
|
|
5313
5316
|
e && (e.textContent = "Start");
|
|
5314
5317
|
}
|
|
@@ -5328,28 +5331,30 @@ var xO = class {
|
|
|
5328
5331
|
this._updateMapGeometry(t);
|
|
5329
5332
|
}
|
|
5330
5333
|
_finishDrawing() {
|
|
5331
|
-
|
|
5332
|
-
|
|
5333
|
-
|
|
5334
|
-
}
|
|
5335
|
-
if (this._state.mode === "area" && this._state.currentPoints.length < 3) {
|
|
5336
|
-
this._cancelDrawing();
|
|
5337
|
-
return;
|
|
5338
|
-
}
|
|
5339
|
-
const e = {
|
|
5334
|
+
const e = this._state.mode === "area" ? 3 : 2;
|
|
5335
|
+
if (this._state.currentPoints.length < e) return;
|
|
5336
|
+
const t = {
|
|
5340
5337
|
id: Ro("measurement"),
|
|
5341
5338
|
mode: this._state.mode,
|
|
5342
5339
|
points: [...this._state.currentPoints],
|
|
5343
5340
|
segments: [...this._state.currentSegments]
|
|
5344
5341
|
};
|
|
5345
|
-
this._state.mode === "distance" ?
|
|
5346
|
-
const
|
|
5347
|
-
|
|
5342
|
+
this._state.mode === "distance" ? t.distance = this._state.currentValue : t.area = this._state.currentValue, this._state.measurements.push(t), this._stopDrawing(), this._updateMapGeometry(), this._updateMeasurementsList();
|
|
5343
|
+
const n = this._panel?.querySelector(".clear-btn");
|
|
5344
|
+
n && (n.disabled = !1), this._emit("drawend", { measurement: t }), this._emit("measurementadd", { measurement: t }), this._panel && this._startDrawing();
|
|
5345
|
+
}
|
|
5346
|
+
_finishOnDoubleClick() {
|
|
5347
|
+
const e = this._state.currentPoints;
|
|
5348
|
+
if (this._map && e.length >= 2) {
|
|
5349
|
+
const t = e[e.length - 1], n = e[e.length - 2], i = this._map.project([t.lng, t.lat]), s = this._map.project([n.lng, n.lat]);
|
|
5350
|
+
Math.hypot(i.x - s.x, i.y - s.y) < 6 && (e.pop(), this._updateMeasurement());
|
|
5351
|
+
}
|
|
5352
|
+
this._finishDrawing();
|
|
5348
5353
|
}
|
|
5349
5354
|
_cancelDrawing() {
|
|
5350
5355
|
this._stopDrawing(), this._clearMarkers(), this._state.currentPoints = [], this._state.currentValue = 0, this._state.currentSegments = [], this._updateMapGeometry();
|
|
5351
5356
|
const e = this._panel?.querySelector(".measure-result");
|
|
5352
|
-
e && (e.style.display = "none"), this._instructionsEl && (this._instructionsEl.textContent = "Click
|
|
5357
|
+
e && (e.style.display = "none"), this._instructionsEl && (this._instructionsEl.textContent = "Click the map to add points. Double-click or right-click to finish.");
|
|
5353
5358
|
}
|
|
5354
5359
|
_updateMeasurement() {
|
|
5355
5360
|
const e = this._state.currentPoints;
|