@watergis/maplibre-gl-terradraw 0.4.3 → 0.5.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/dist/maplibre-gl-terradraw.es.js +78 -45
- package/dist/maplibre-gl-terradraw.es.js.map +1 -1
- package/dist/maplibre-gl-terradraw.umd.js +1 -1
- package/dist/maplibre-gl-terradraw.umd.js.map +1 -1
- package/dist/types/MaplibreTerradrawControl.d.ts +10 -2
- package/dist/types/MaplibreTerradrawControl.d.ts.map +1 -1
- package/dist/types/interfaces/EventTypes.d.ts +2 -0
- package/dist/types/interfaces/EventTypes.d.ts.map +1 -0
- package/dist/types/interfaces/index.d.ts +1 -0
- package/dist/types/interfaces/index.d.ts.map +1 -1
- package/package.json +6 -5
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var ne = Object.defineProperty;
|
|
2
2
|
var ae = (n, t, e) => t in n ? ne(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
|
|
3
|
-
var
|
|
3
|
+
var B = (n, t, e) => ae(n, typeof t != "symbol" ? t + "" : t, e);
|
|
4
4
|
function v() {
|
|
5
5
|
return v = Object.assign ? Object.assign.bind() : function(n) {
|
|
6
6
|
for (var t = 1; t < arguments.length; t++) {
|
|
@@ -343,8 +343,8 @@ function Ft(n) {
|
|
|
343
343
|
});
|
|
344
344
|
});
|
|
345
345
|
}
|
|
346
|
-
var
|
|
347
|
-
Ft(It), Ft(Dt),
|
|
346
|
+
var Ot, kt, jt, M;
|
|
347
|
+
Ft(It), Ft(Dt), Ot = It, kt = function(n, t, e) {
|
|
348
348
|
const i = n.length;
|
|
349
349
|
e = e > 1 ? e : 2, t === void 0 && (t = e > 2 ? n.slice() : new Array(i));
|
|
350
350
|
for (let o = 0; o < i; o += e) {
|
|
@@ -359,8 +359,8 @@ Ft(It), Ft(Dt), kt = It, Ot = function(n, t, e) {
|
|
|
359
359
|
for (let o = 0; o < i; o += e) t[o] = 180 * n[o] / H, t[o + 1] = 360 * Math.atan(Math.exp(n[o + 1] / et)) / Math.PI - 90;
|
|
360
360
|
return t;
|
|
361
361
|
}, Dt.forEach(function(n) {
|
|
362
|
-
|
|
363
|
-
dt(n, t,
|
|
362
|
+
Ot.forEach(function(t) {
|
|
363
|
+
dt(n, t, kt), dt(t, n, jt);
|
|
364
364
|
});
|
|
365
365
|
});
|
|
366
366
|
(function(n) {
|
|
@@ -380,7 +380,7 @@ var A;
|
|
|
380
380
|
(function(n) {
|
|
381
381
|
n.Drawing = "drawing", n.Select = "select", n.Static = "static", n.Render = "render";
|
|
382
382
|
})(A || (A = {}));
|
|
383
|
-
class
|
|
383
|
+
class k {
|
|
384
384
|
get state() {
|
|
385
385
|
return this._state;
|
|
386
386
|
}
|
|
@@ -464,7 +464,7 @@ class O {
|
|
|
464
464
|
return t === void 0 ? e : typeof t == "function" ? t(i) : t;
|
|
465
465
|
}
|
|
466
466
|
}
|
|
467
|
-
class ye extends
|
|
467
|
+
class ye extends k {
|
|
468
468
|
constructor(...t) {
|
|
469
469
|
super(...t), this.type = A.Select;
|
|
470
470
|
}
|
|
@@ -483,7 +483,7 @@ function $t(n) {
|
|
|
483
483
|
function J(n) {
|
|
484
484
|
return n % (2 * Math.PI) * 180 / Math.PI;
|
|
485
485
|
}
|
|
486
|
-
const Lt = 57.29577951308232, Nt = 0.017453292519943295, ct = 6378137, x = (n, t) => ({ x: n === 0 ? 0 : n * Nt * ct, y: t === 0 ? 0 : Math.log(Math.tan(Math.PI / 4 + t * Nt / 2)) * ct }),
|
|
486
|
+
const Lt = 57.29577951308232, Nt = 0.017453292519943295, ct = 6378137, x = (n, t) => ({ x: n === 0 ? 0 : n * Nt * ct, y: t === 0 ? 0 : Math.log(Math.tan(Math.PI / 4 + t * Nt / 2)) * ct }), O = (n, t) => ({ lng: n === 0 ? 0 : Lt * (n / ct), lat: t === 0 ? 0 : (2 * Math.atan(Math.exp(t / ct)) - Math.PI / 2) * Lt });
|
|
487
487
|
function me(n, t, e) {
|
|
488
488
|
const i = D(n[0]), o = D(n[1]), s = D(e), r = $t(t), a = Math.asin(Math.sin(o) * Math.cos(r) + Math.cos(o) * Math.sin(r) * Math.cos(s));
|
|
489
489
|
return [J(i + Math.atan2(Math.sin(s) * Math.sin(r) * Math.cos(o), Math.cos(r) - Math.sin(o) * Math.sin(a))), J(a)];
|
|
@@ -513,8 +513,8 @@ function St(n) {
|
|
|
513
513
|
function s(r, a, l, h) {
|
|
514
514
|
const d = e[r][a], c = e[r][a + 1], u = e[l][h], g = e[l][h + 1], p = function(m, C, P, b) {
|
|
515
515
|
if (rt(m, P) || rt(m, b) || rt(C, P) || rt(b, P)) return null;
|
|
516
|
-
const w = m[0], S = m[1], I = C[0], W = C[1], R = P[0], T = P[1],
|
|
517
|
-
return mt === 0 ? null : [((w * W - S * I) * (R -
|
|
516
|
+
const w = m[0], S = m[1], I = C[0], W = C[1], R = P[0], T = P[1], L = b[0], ot = b[1], mt = (w - I) * (T - ot) - (S - W) * (R - L);
|
|
517
|
+
return mt === 0 ? null : [((w * W - S * I) * (R - L) - (w - I) * (R * ot - T * L)) / mt, ((w * W - S * I) * (T - ot) - (S - W) * (R * ot - T * L)) / mt];
|
|
518
518
|
}(d, c, u, g);
|
|
519
519
|
if (p === null) return;
|
|
520
520
|
let y, f;
|
|
@@ -540,7 +540,7 @@ function U(n, t) {
|
|
|
540
540
|
function Jt(n, t) {
|
|
541
541
|
return U(n, t) && !St(n);
|
|
542
542
|
}
|
|
543
|
-
class fe extends
|
|
543
|
+
class fe extends k {
|
|
544
544
|
constructor(t) {
|
|
545
545
|
var e;
|
|
546
546
|
super(t), this.mode = "circle", this.center = void 0, this.clickCount = 0, this.currentCircleId = void 0, this.keyEvents = void 0, this.cursors = void 0, this.startingRadiusKilometers = 1e-5;
|
|
@@ -617,7 +617,7 @@ class fe extends O {
|
|
|
617
617
|
i = function(s) {
|
|
618
618
|
const { center: r, radiusKilometers: a, coordinatePrecision: l } = s, h = s.steps ? s.steps : 64, d = 1e3 * a, [c, u] = r, { x: g, y: p } = x(c, u), y = [];
|
|
619
619
|
for (let f = 0; f < h; f++) {
|
|
620
|
-
const m = 360 * f / h * Math.PI / 180, C = d * Math.cos(m), P = d * Math.sin(m), [b, w] = [g + C, p + P], { lng: S, lat: I } =
|
|
620
|
+
const m = 360 * f / h * Math.PI / 180, C = d * Math.cos(m), P = d * Math.sin(m), [b, w] = [g + C, p + P], { lng: S, lat: I } = O(b, w);
|
|
621
621
|
y.push([E(S, l), E(I, l)]);
|
|
622
622
|
}
|
|
623
623
|
return y.push(y[0]), { type: "Feature", geometry: { type: "Polygon", coordinates: [y] }, properties: {} };
|
|
@@ -631,7 +631,7 @@ class fe extends O {
|
|
|
631
631
|
}
|
|
632
632
|
}
|
|
633
633
|
}
|
|
634
|
-
class Ce extends
|
|
634
|
+
class Ce extends k {
|
|
635
635
|
constructor(t) {
|
|
636
636
|
super(t), this.mode = "freehand", this.startingClick = !1, this.currentId = void 0, this.closingPointId = void 0, this.minDistance = void 0, this.keyEvents = void 0, this.cursors = void 0, this.preventPointsNearClose = void 0;
|
|
637
637
|
const e = { start: "crosshair", close: "pointer" };
|
|
@@ -833,7 +833,7 @@ class Pe extends F {
|
|
|
833
833
|
function $(n, t) {
|
|
834
834
|
return n[0] === t[0] && n[1] === t[1];
|
|
835
835
|
}
|
|
836
|
-
class xe extends
|
|
836
|
+
class xe extends k {
|
|
837
837
|
constructor(t) {
|
|
838
838
|
super(t), this.mode = "linestring", this.currentCoordinate = 0, this.currentId = void 0, this.closingPointId = void 0, this.keyEvents = void 0, this.snappingEnabled = void 0, this.cursors = void 0, this.mouseMove = !1, this.insertCoordinates = void 0, this.lastCommitedCoordinates = void 0, this.snapping = void 0, this.insertPoint = void 0;
|
|
839
839
|
const e = { start: "crosshair", close: "pointer" };
|
|
@@ -947,7 +947,7 @@ class xe extends O {
|
|
|
947
947
|
function Qt(n, t) {
|
|
948
948
|
return n.geometry.type === "Point" && yt(n.geometry.coordinates, t);
|
|
949
949
|
}
|
|
950
|
-
class Me extends
|
|
950
|
+
class Me extends k {
|
|
951
951
|
constructor(t) {
|
|
952
952
|
super(t), this.mode = "point", this.cursors = void 0;
|
|
953
953
|
const e = { create: "crosshair" };
|
|
@@ -1014,7 +1014,7 @@ class Se extends F {
|
|
|
1014
1014
|
return { isClosing: o < this.pointerDistance, isPreviousClosing: s < this.pointerDistance };
|
|
1015
1015
|
}
|
|
1016
1016
|
}
|
|
1017
|
-
class be extends
|
|
1017
|
+
class be extends k {
|
|
1018
1018
|
constructor(t) {
|
|
1019
1019
|
super(t), this.mode = "polygon", this.currentCoordinate = 0, this.currentId = void 0, this.keyEvents = void 0, this.snappingEnabled = void 0, this.snapping = void 0, this.pixelDistance = void 0, this.closingPoints = void 0, this.cursors = void 0, this.mouseMove = !1;
|
|
1020
1020
|
const e = { start: "crosshair", close: "pointer" };
|
|
@@ -1123,7 +1123,7 @@ class be extends O {
|
|
|
1123
1123
|
return !!super.validateFeature(t) && t.properties.mode === this.mode && U(t, this.coordinatePrecision);
|
|
1124
1124
|
}
|
|
1125
1125
|
}
|
|
1126
|
-
class we extends
|
|
1126
|
+
class we extends k {
|
|
1127
1127
|
constructor(t) {
|
|
1128
1128
|
super(t), this.mode = "rectangle", this.center = void 0, this.clickCount = 0, this.currentRectangleId = void 0, this.keyEvents = void 0, this.cursors = void 0;
|
|
1129
1129
|
const e = { start: "crosshair" };
|
|
@@ -1183,7 +1183,7 @@ class we extends O {
|
|
|
1183
1183
|
return !!super.validateFeature(t) && t.properties.mode === this.mode && Jt(t, this.coordinatePrecision);
|
|
1184
1184
|
}
|
|
1185
1185
|
}
|
|
1186
|
-
class ht extends
|
|
1186
|
+
class ht extends k {
|
|
1187
1187
|
constructor(t) {
|
|
1188
1188
|
super({ styles: t.styles }), this.type = A.Render, this.mode = "render", this.mode = t.modeName;
|
|
1189
1189
|
}
|
|
@@ -1390,7 +1390,7 @@ class Fe extends F {
|
|
|
1390
1390
|
} else i.type === "Point" && (this.store.updateGeometry([{ id: this.draggedFeatureId, geometry: { type: "Point", coordinates: o } }]), this.dragPosition = [t.lng, t.lat]);
|
|
1391
1391
|
}
|
|
1392
1392
|
}
|
|
1393
|
-
class
|
|
1393
|
+
class Oe extends F {
|
|
1394
1394
|
constructor(t, e, i, o) {
|
|
1395
1395
|
super(t), this.config = void 0, this.pixelDistance = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.draggedCoordinate = { id: null, index: -1 }, this.config = t, this.pixelDistance = e, this.selectionPoints = i, this.midPoints = o;
|
|
1396
1396
|
}
|
|
@@ -1474,7 +1474,7 @@ function pt(n) {
|
|
|
1474
1474
|
return { x: o / i, y: s / i };
|
|
1475
1475
|
}(t);
|
|
1476
1476
|
}
|
|
1477
|
-
class
|
|
1477
|
+
class ke extends F {
|
|
1478
1478
|
constructor(t, e, i) {
|
|
1479
1479
|
super(t), this.config = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.lastBearing = void 0, this.config = t, this.selectionPoints = e, this.midPoints = i;
|
|
1480
1480
|
}
|
|
@@ -1493,7 +1493,7 @@ class Oe extends F {
|
|
|
1493
1493
|
if (u === 0 || u === 360 || u === -360) return c;
|
|
1494
1494
|
const g = 0.017453292519943295 * u, p = (c.geometry.type === "Polygon" ? c.geometry.coordinates[0] : c.geometry.coordinates).map(([m, C]) => x(m, C)), y = p.reduce((m, C) => ({ x: m.x + C.x, y: m.y + C.y }), { x: 0, y: 0 });
|
|
1495
1495
|
y.x /= p.length, y.y /= p.length;
|
|
1496
|
-
const f = p.map((m) => ({ x: y.x + (m.x - y.x) * Math.cos(g) - (m.y - y.y) * Math.sin(g), y: y.y + (m.x - y.x) * Math.sin(g) + (m.y - y.y) * Math.cos(g) })).map(({ x: m, y: C }) => [
|
|
1496
|
+
const f = p.map((m) => ({ x: y.x + (m.x - y.x) * Math.cos(g) - (m.y - y.y) * Math.sin(g), y: y.y + (m.x - y.x) * Math.sin(g) + (m.y - y.y) * Math.cos(g) })).map(({ x: m, y: C }) => [O(m, C).lng, O(m, C).lat]);
|
|
1497
1497
|
c.geometry.type === "Polygon" ? c.geometry.coordinates[0] = f : c.geometry.coordinates = f;
|
|
1498
1498
|
})(a, -(this.lastBearing - r));
|
|
1499
1499
|
} else {
|
|
@@ -1540,10 +1540,10 @@ class je extends F {
|
|
|
1540
1540
|
if (!this.lastDistance) return void (this.lastDistance = a);
|
|
1541
1541
|
const h = 1 - (this.lastDistance - a) / a;
|
|
1542
1542
|
if (this.config.projection === "web-mercator") {
|
|
1543
|
-
const { lng: g, lat: p } =
|
|
1543
|
+
const { lng: g, lat: p } = O(l.x, l.y);
|
|
1544
1544
|
(function(y, f, m) {
|
|
1545
1545
|
if (f === 1) return y;
|
|
1546
|
-
const C = (y.geometry.type === "Polygon" ? y.geometry.coordinates[0] : y.geometry.coordinates).map(([w, S]) => x(w, S)), P = x(m[0], m[1]), b = C.map((w) => ({ x: P.x + (w.x - P.x) * f, y: P.y + (w.y - P.y) * f })).map(({ x: w, y: S }) => [
|
|
1546
|
+
const C = (y.geometry.type === "Polygon" ? y.geometry.coordinates[0] : y.geometry.coordinates).map(([w, S]) => x(w, S)), P = x(m[0], m[1]), b = C.map((w) => ({ x: P.x + (w.x - P.x) * f, y: P.y + (w.y - P.y) * f })).map(({ x: w, y: S }) => [O(w, S).lng, O(w, S).lat]);
|
|
1547
1547
|
y.geometry.type === "Polygon" ? y.geometry.coordinates[0] = b : y.geometry.coordinates = b;
|
|
1548
1548
|
})(r, h, [g, p]);
|
|
1549
1549
|
} else this.config.projection === "globe" && function(g, p, y, f = "xy") {
|
|
@@ -1672,7 +1672,7 @@ class We extends F {
|
|
|
1672
1672
|
}
|
|
1673
1673
|
performWebMercatorScale(t, e, i, o, s) {
|
|
1674
1674
|
t.forEach((r) => {
|
|
1675
|
-
const { x: a, y: l } = x(r[0], r[1]), h = e + (a - e) * o, d = i + (l - i) * s, { lng: c, lat: u } =
|
|
1675
|
+
const { x: a, y: l } = x(r[0], r[1]), h = e + (a - e) * o, d = i + (l - i) * s, { lng: c, lat: u } = O(h, d);
|
|
1676
1676
|
r[0] = c, r[1] = u;
|
|
1677
1677
|
});
|
|
1678
1678
|
}
|
|
@@ -1746,7 +1746,7 @@ class Be extends ye {
|
|
|
1746
1746
|
this._state = "selecting";
|
|
1747
1747
|
}
|
|
1748
1748
|
registerBehaviors(t) {
|
|
1749
|
-
this.pixelDistance = new wt(t), this.clickBoundingBox = new bt(t), this.featuresAtMouseEvent = new De(t, this.clickBoundingBox, this.pixelDistance), this.selectionPoints = new _e(t), this.midPoints = new Ie(t, this.selectionPoints), this.rotateFeature = new
|
|
1749
|
+
this.pixelDistance = new wt(t), this.clickBoundingBox = new bt(t), this.featuresAtMouseEvent = new De(t, this.clickBoundingBox, this.pixelDistance), this.selectionPoints = new _e(t), this.midPoints = new Ie(t, this.selectionPoints), this.rotateFeature = new ke(t, this.selectionPoints, this.midPoints), this.scaleFeature = new je(t, this.selectionPoints, this.midPoints), this.dragFeature = new Fe(t, this.featuresAtMouseEvent, this.selectionPoints, this.midPoints), this.dragCoordinate = new Oe(t, this.pixelDistance, this.selectionPoints, this.midPoints), this.dragCoordinateResizeFeature = new We(t, this.pixelDistance, this.selectionPoints, this.midPoints);
|
|
1750
1750
|
}
|
|
1751
1751
|
deselectFeature() {
|
|
1752
1752
|
this.deselect();
|
|
@@ -1884,7 +1884,7 @@ class Be extends ye {
|
|
|
1884
1884
|
return e;
|
|
1885
1885
|
}
|
|
1886
1886
|
}
|
|
1887
|
-
class Le extends
|
|
1887
|
+
class Le extends k {
|
|
1888
1888
|
constructor(...t) {
|
|
1889
1889
|
super(...t), this.type = A.Static, this.mode = "static";
|
|
1890
1890
|
}
|
|
@@ -2289,7 +2289,7 @@ function Kt(n, t, e) {
|
|
|
2289
2289
|
let o = j(t, e) - i;
|
|
2290
2290
|
return o < 0 && (o += 360), 180 - Math.abs(o - 90 - 90);
|
|
2291
2291
|
}
|
|
2292
|
-
class Ke extends
|
|
2292
|
+
class Ke extends k {
|
|
2293
2293
|
constructor(t) {
|
|
2294
2294
|
super(t), this.mode = "angled-rectangle", this.currentCoordinate = 0, this.currentId = void 0, this.keyEvents = void 0, this.cursors = void 0, this.mouseMove = !1;
|
|
2295
2295
|
const e = { start: "crosshair", close: "pointer" };
|
|
@@ -2321,7 +2321,7 @@ class Ke extends O {
|
|
|
2321
2321
|
const o = e[0], s = e[1], r = te(o, s, this.coordinatePrecision, this.project, this.unproject), a = x(o[0], o[1]), l = x(r[0], r[1]), h = x(s[0], s[1]), d = x(t.lng, t.lat), c = _(d, a) < _(d, h), u = Kt(a, l, d), g = c ? 90 - u : Kt(a, l, d) - 90, p = _(l, d), y = Math.cos(D(g)) * p, f = j(a, h) + (function(w, S, I) {
|
|
2322
2322
|
const W = (I.x - S.x) * (w.y - S.y) - (I.y - S.y) * (w.x - S.x);
|
|
2323
2323
|
return W > 1e-10 ? "left" : W < -1e-10 ? "right" : "left";
|
|
2324
|
-
}(a, h, d) === "right" ? -90 : 90), m = it(a, y, f), C = it(h, y, f), P =
|
|
2324
|
+
}(a, h, d) === "right" ? -90 : 90), m = it(a, y, f), C = it(h, y, f), P = O(m.x, m.y), b = O(C.x, C.y);
|
|
2325
2325
|
i = [e[0], e[1], [b.lng, b.lat], [P.lng, P.lat], e[0]];
|
|
2326
2326
|
}
|
|
2327
2327
|
i && this.updatePolygonGeometry(this.currentId, i, M.Provisional);
|
|
@@ -2369,7 +2369,7 @@ class Ke extends O {
|
|
|
2369
2369
|
function re(n, t, e) {
|
|
2370
2370
|
return (t.x - n.x) * (e.y - n.y) - (t.y - n.y) * (e.x - n.x) <= 0;
|
|
2371
2371
|
}
|
|
2372
|
-
class ze extends
|
|
2372
|
+
class ze extends k {
|
|
2373
2373
|
constructor(t) {
|
|
2374
2374
|
super(t), this.mode = "sector", this.currentCoordinate = 0, this.currentId = void 0, this.keyEvents = void 0, this.direction = void 0, this.arcPoints = void 0, this.cursors = void 0, this.mouseMove = !1;
|
|
2375
2375
|
const e = { start: "crosshair", close: "pointer" };
|
|
@@ -2410,7 +2410,7 @@ class ze extends O {
|
|
|
2410
2410
|
const C = (this.direction === "anticlockwise" ? 1 : -1) * m / g;
|
|
2411
2411
|
p.push(s);
|
|
2412
2412
|
for (let P = 0; P <= g; P++) {
|
|
2413
|
-
const b = it(a, d, y + P * C), { lng: w, lat: S } =
|
|
2413
|
+
const b = it(a, d, y + P * C), { lng: w, lat: S } = O(b.x, b.y), I = [E(w, this.coordinatePrecision), E(S, this.coordinatePrecision)];
|
|
2414
2414
|
I[0] !== p[p.length - 1][0] && I[1] !== p[p.length - 1][1] && p.push(I);
|
|
2415
2415
|
}
|
|
2416
2416
|
p.push(o), i = [...p];
|
|
@@ -2457,7 +2457,7 @@ class ze extends O {
|
|
|
2457
2457
|
return !!super.validateFeature(t) && t.properties.mode === this.mode && U(t, this.coordinatePrecision);
|
|
2458
2458
|
}
|
|
2459
2459
|
}
|
|
2460
|
-
class Ye extends
|
|
2460
|
+
class Ye extends k {
|
|
2461
2461
|
constructor(t) {
|
|
2462
2462
|
super(t), this.mode = "sensor", this.currentCoordinate = 0, this.currentId = void 0, this.currentInitialArcId = void 0, this.currentStartingPointId = void 0, this.keyEvents = void 0, this.direction = void 0, this.arcPoints = void 0, this.cursors = void 0, this.mouseMove = !1;
|
|
2463
2463
|
const e = { start: "crosshair", close: "pointer" };
|
|
@@ -2492,7 +2492,7 @@ class Ye extends O {
|
|
|
2492
2492
|
this.direction === "anticlockwise" ? (f = y - p, f < 0 && (f += 360)) : (f = p - y, f < 0 && (f += 360));
|
|
2493
2493
|
const m = (this.direction === "anticlockwise" ? 1 : -1) * f / u;
|
|
2494
2494
|
for (let C = 0; C <= u; C++) {
|
|
2495
|
-
const P = it(l, h, p + C * m), { lng: b, lat: w } =
|
|
2495
|
+
const P = it(l, h, p + C * m), { lng: b, lat: w } = O(P.x, P.y), S = [E(b, this.coordinatePrecision), E(w, this.coordinatePrecision)];
|
|
2496
2496
|
S[0] !== g[g.length - 1][0] && S[1] !== g[g.length - 1][1] && g.push(S);
|
|
2497
2497
|
}
|
|
2498
2498
|
this.updateLineStringGeometry(this.currentInitialArcId, g, M.Provisional);
|
|
@@ -2503,8 +2503,8 @@ class Ye extends O {
|
|
|
2503
2503
|
if (this.notInSector({ normalizedCursor: m, normalizedStart: y, normalizedEnd: f, direction: this.direction })) return;
|
|
2504
2504
|
const C = this.getDeltaBearing(this.direction, y, f), P = this.arcPoints, b = (this.direction === "anticlockwise" ? 1 : -1) * C / P, w = _(h, c), S = [];
|
|
2505
2505
|
for (let I = 0; I <= P; I++) {
|
|
2506
|
-
const W = it(h, w, y + I * b), { lng: R, lat: T } =
|
|
2507
|
-
|
|
2506
|
+
const W = it(h, w, y + I * b), { lng: R, lat: T } = O(W.x, W.y), L = [E(R, this.coordinatePrecision), E(T, this.coordinatePrecision)];
|
|
2507
|
+
L[0] !== e[e.length - 1][0] && L[1] !== e[e.length - 1][1] && S.unshift(L);
|
|
2508
2508
|
}
|
|
2509
2509
|
e.push(...S), e.push(e[0]), this.currentId ? this.updatePolygonGeometry(this.currentId, e, M.Provisional) : [this.currentId] = this.store.create([{ geometry: { type: "Polygon", coordinates: [e] }, properties: { mode: this.mode } }]);
|
|
2510
2510
|
}
|
|
@@ -2883,13 +2883,14 @@ class Ze {
|
|
|
2883
2883
|
* @param options Plugin control options
|
|
2884
2884
|
*/
|
|
2885
2885
|
constructor(t) {
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2886
|
+
B(this, "controlContainer");
|
|
2887
|
+
B(this, "map");
|
|
2888
|
+
B(this, "modeButtons", {});
|
|
2889
|
+
B(this, "isExpanded", !1);
|
|
2890
|
+
B(this, "terradraw");
|
|
2891
|
+
B(this, "options", $e);
|
|
2892
|
+
B(this, "events", {});
|
|
2893
|
+
B(this, "defaultMode", "render");
|
|
2893
2894
|
this.modeButtons = {}, t && (this.options = Object.assign(this.options, t));
|
|
2894
2895
|
}
|
|
2895
2896
|
getDefaultPosition() {
|
|
@@ -2915,6 +2916,8 @@ class Ze {
|
|
|
2915
2916
|
}
|
|
2916
2917
|
i.push(h);
|
|
2917
2918
|
} else e[l] && i.push(e[l]);
|
|
2919
|
+
}), i.forEach((l) => {
|
|
2920
|
+
l.state !== "unregistered" && (l._state = "unregistered");
|
|
2918
2921
|
}), (a = (r = this.options) == null ? void 0 : r.modes) != null && a.includes("render") || (i.push(
|
|
2919
2922
|
new ht({
|
|
2920
2923
|
modeName: "default",
|
|
@@ -2933,17 +2936,47 @@ class Ze {
|
|
|
2933
2936
|
onRemove() {
|
|
2934
2937
|
!this.controlContainer || !this.controlContainer.parentNode || !this.map || (this.deactivate(), this.modeButtons = {}, this.terradraw = void 0, this.map = void 0, this.controlContainer.parentNode.removeChild(this.controlContainer));
|
|
2935
2938
|
}
|
|
2939
|
+
/**
|
|
2940
|
+
* Register an event for the plugin
|
|
2941
|
+
* @param event event type
|
|
2942
|
+
* @param callback
|
|
2943
|
+
*/
|
|
2944
|
+
on(t, e) {
|
|
2945
|
+
this.events[t] ? this.events[t].push(e) : this.events[t] = [e];
|
|
2946
|
+
}
|
|
2947
|
+
/**
|
|
2948
|
+
* Unregister an event for the plugin
|
|
2949
|
+
* @param event event type
|
|
2950
|
+
* @param callback
|
|
2951
|
+
* @returns
|
|
2952
|
+
*/
|
|
2953
|
+
off(t, e) {
|
|
2954
|
+
if (!this.events[t]) return;
|
|
2955
|
+
const i = this.events[t].findIndex((o) => o === e);
|
|
2956
|
+
i !== -1 && this.events[t].splice(i, 1);
|
|
2957
|
+
}
|
|
2958
|
+
/**
|
|
2959
|
+
* Dispatch an event. Pass the current snapshot of features and mode
|
|
2960
|
+
* @param event event type
|
|
2961
|
+
*/
|
|
2962
|
+
dispatchEvent(t) {
|
|
2963
|
+
this.events[t] && this.events[t].forEach((e) => {
|
|
2964
|
+
var s, r;
|
|
2965
|
+
const i = (s = this.terradraw) == null ? void 0 : s.getSnapshot(), o = i == null ? void 0 : i.filter((a) => a.properties.selected === !0);
|
|
2966
|
+
e({ feature: o, mode: (r = this.terradraw) == null ? void 0 : r.getMode() });
|
|
2967
|
+
});
|
|
2968
|
+
}
|
|
2936
2969
|
/**
|
|
2937
2970
|
* Activate Terra Draw to start drawing
|
|
2938
2971
|
*/
|
|
2939
2972
|
activate() {
|
|
2940
|
-
this.terradraw && (this.terradraw.enabled || this.terradraw.start());
|
|
2973
|
+
this.terradraw && (this.terradraw.enabled || (this.terradraw.start(), this.dispatchEvent("mode-changed")));
|
|
2941
2974
|
}
|
|
2942
2975
|
/**
|
|
2943
2976
|
* Deactivate Terra Draw to stop drawing
|
|
2944
2977
|
*/
|
|
2945
2978
|
deactivate() {
|
|
2946
|
-
this.terradraw && this.terradraw.enabled && (this.resetActiveMode(), this.terradraw.stop());
|
|
2979
|
+
this.terradraw && this.terradraw.enabled && (this.resetActiveMode(), this.dispatchEvent("mode-changed"), this.terradraw.stop());
|
|
2947
2980
|
}
|
|
2948
2981
|
/**
|
|
2949
2982
|
* Get the Terra Draw instance.
|
|
@@ -2988,7 +3021,7 @@ class Ze {
|
|
|
2988
3021
|
addTerradrawButton(t) {
|
|
2989
3022
|
const e = document.createElement("button");
|
|
2990
3023
|
e.type = "button", this.modeButtons[t] = e, t === "render" ? (e.classList.add(`maplibregl-terradraw-${t}-button`), this.isExpanded && e.classList.add("enabled"), e.type = "button", e.title = this.capitalize("expand or collapse drawing tool"), e.addEventListener("click", this.toggleEditor.bind(this))) : (e.classList.add("maplibregl-terradraw-add-control"), this.isExpanded || e.classList.add("hidden"), e.title = this.capitalize(t.replace(/-/g, " ")), t === "delete" ? (e.classList.add(`maplibregl-terradraw-${t}-button`), e.addEventListener("click", () => {
|
|
2991
|
-
this.terradraw && this.terradraw.enabled && (this.terradraw.clear(), this.deactivate(), this.toggleDeleteSelectionButton());
|
|
3024
|
+
this.terradraw && this.terradraw.enabled && (this.terradraw.clear(), this.deactivate(), this.toggleDeleteSelectionButton(), this.dispatchEvent("feature-deleted"));
|
|
2992
3025
|
})) : t === "delete-selection" ? (e.classList.add(`maplibregl-terradraw-${t}-button`), e.classList.add("hidden-delete-selection"), e.addEventListener("click", () => {
|
|
2993
3026
|
var s;
|
|
2994
3027
|
if (!this.terradraw || !this.terradraw.enabled) return;
|
|
@@ -2997,7 +3030,7 @@ class Ze {
|
|
|
2997
3030
|
const r = this.terradraw.getMode();
|
|
2998
3031
|
this.terradraw.setMode(this.defaultMode);
|
|
2999
3032
|
const a = o.map((l) => l.id);
|
|
3000
|
-
this.terradraw.removeFeatures(a), this.terradraw.setMode(r);
|
|
3033
|
+
this.terradraw.removeFeatures(a), this.terradraw.setMode(r), this.dispatchEvent("feature-deleted");
|
|
3001
3034
|
}
|
|
3002
3035
|
this.toggleDeleteSelectionButton();
|
|
3003
3036
|
})) : (e.classList.add(`maplibregl-terradraw-add-${t}-button`), e.addEventListener("click", () => {
|