@watergis/maplibre-gl-terradraw 0.0.6 → 0.1.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/dist/maplibre-gl-terradraw.es.js +142 -125
- 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 +0 -1
- package/dist/types/MaplibreTerradrawControl.d.ts.map +1 -1
- package/dist/types/constants/defaultControlOptions.d.ts.map +1 -1
- package/dist/types/constants/getDefaultModeOptions.d.ts +3 -0
- package/dist/types/constants/getDefaultModeOptions.d.ts.map +1 -0
- package/dist/types/constants/index.d.ts +1 -0
- package/dist/types/constants/index.d.ts.map +1 -1
- package/dist/types/interfaces/ControlOptions.d.ts +4 -8
- package/dist/types/interfaces/ControlOptions.d.ts.map +1 -1
- package/dist/types/interfaces/ModeOptions.d.ts +5 -0
- package/dist/types/interfaces/ModeOptions.d.ts.map +1 -0
- package/dist/types/interfaces/TerradrawModeClass.d.ts +3 -0
- package/dist/types/interfaces/TerradrawModeClass.d.ts.map +1 -0
- package/dist/types/interfaces/index.d.ts +2 -0
- package/dist/types/interfaces/index.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/types/helpers/getTerraDrawModes.d.ts +0 -3
- package/dist/types/helpers/getTerraDrawModes.d.ts.map +0 -1
- package/dist/types/helpers/index.d.ts +0 -2
- package/dist/types/helpers/index.d.ts.map +0 -1
|
@@ -515,7 +515,7 @@ var Qt = class {
|
|
|
515
515
|
return this.getPointResolutionFunc_;
|
|
516
516
|
}
|
|
517
517
|
};
|
|
518
|
-
const J = 6378137,
|
|
518
|
+
const J = 6378137, X = Math.PI * J, Pe = [-X, -X, X, X], Me = [-180, -85, 180, 85], it = J * Math.log(Math.tan(Math.PI / 2));
|
|
519
519
|
class V extends Qt {
|
|
520
520
|
constructor(t) {
|
|
521
521
|
super({ code: t, units: "m", extent: Pe, global: !0, worldExtent: Me, getPointResolution: function(e, i) {
|
|
@@ -523,13 +523,13 @@ class V extends Qt {
|
|
|
523
523
|
} });
|
|
524
524
|
}
|
|
525
525
|
}
|
|
526
|
-
const Ft = [new V("EPSG:3857"), new V("EPSG:102100"), new V("EPSG:102113"), new V("EPSG:900913"), new V("http://www.opengis.net/def/crs/EPSG/0/3857"), new V("http://www.opengis.net/gml/srs/epsg.xml#3857")],
|
|
526
|
+
const Ft = [new V("EPSG:3857"), new V("EPSG:102100"), new V("EPSG:102113"), new V("EPSG:900913"), new V("http://www.opengis.net/def/crs/EPSG/0/3857"), new V("http://www.opengis.net/gml/srs/epsg.xml#3857")], Ot = [-180, -90, 180, 90], _e = 6378137 * Math.PI / 180;
|
|
527
527
|
class N extends Qt {
|
|
528
528
|
constructor(t, e) {
|
|
529
|
-
super({ code: t, units: "degrees", extent:
|
|
529
|
+
super({ code: t, units: "degrees", extent: Ot, axisOrientation: e, global: !0, metersPerUnit: _e, worldExtent: Ot });
|
|
530
530
|
}
|
|
531
531
|
}
|
|
532
|
-
const
|
|
532
|
+
const kt = [new N("CRS:84"), new N("EPSG:4326", "neu"), new N("urn:ogc:def:crs:OGC:1.3:CRS84"), new N("urn:ogc:def:crs:OGC:2:84"), new N("http://www.opengis.net/def/crs/OGC/1.3/CRS84"), new N("http://www.opengis.net/gml/srs/epsg.xml#4326", "neu"), new N("http://www.opengis.net/def/crs/EPSG/0/4326", "neu")];
|
|
533
533
|
let mt = {};
|
|
534
534
|
function at(s, t, e) {
|
|
535
535
|
const i = s.getCode(), o = t.getCode();
|
|
@@ -553,11 +553,11 @@ function jt(s) {
|
|
|
553
553
|
});
|
|
554
554
|
}
|
|
555
555
|
var Lt, Wt, Bt, C;
|
|
556
|
-
jt(Ft), jt(
|
|
556
|
+
jt(Ft), jt(kt), Lt = Ft, Wt = function(s, t, e) {
|
|
557
557
|
const i = s.length;
|
|
558
558
|
e = e > 1 ? e : 2, t === void 0 && (t = e > 2 ? s.slice() : new Array(i));
|
|
559
559
|
for (let o = 0; o < i; o += e) {
|
|
560
|
-
t[o] =
|
|
560
|
+
t[o] = X * s[o] / 180;
|
|
561
561
|
let n = J * Math.log(Math.tan(Math.PI * (+s[o + 1] + 90) / 360));
|
|
562
562
|
n > it ? n = it : n < -it && (n = -it), t[o + 1] = n;
|
|
563
563
|
}
|
|
@@ -565,9 +565,9 @@ jt(Ft), jt(Ot), Lt = Ft, Wt = function(s, t, e) {
|
|
|
565
565
|
}, Bt = function(s, t, e) {
|
|
566
566
|
const i = s.length;
|
|
567
567
|
e = e > 1 ? e : 2, t === void 0 && (t = e > 2 ? s.slice() : new Array(i));
|
|
568
|
-
for (let o = 0; o < i; o += e) t[o] = 180 * s[o] /
|
|
568
|
+
for (let o = 0; o < i; o += e) t[o] = 180 * s[o] / X, t[o + 1] = 360 * Math.atan(Math.exp(s[o + 1] / J)) / Math.PI - 90;
|
|
569
569
|
return t;
|
|
570
|
-
},
|
|
570
|
+
}, kt.forEach(function(s) {
|
|
571
571
|
Lt.forEach(function(t) {
|
|
572
572
|
at(s, t, Wt), at(t, s, Bt);
|
|
573
573
|
});
|
|
@@ -689,13 +689,13 @@ function w(s) {
|
|
|
689
689
|
function ee(s) {
|
|
690
690
|
return s / (Mt / 1e3);
|
|
691
691
|
}
|
|
692
|
-
function
|
|
692
|
+
function T(s) {
|
|
693
693
|
return s % (2 * Math.PI) * 180 / Math.PI;
|
|
694
694
|
}
|
|
695
695
|
const At = 57.29577951308232, Vt = 0.017453292519943295, lt = 6378137, P = (s, t) => ({ x: s === 0 ? 0 : s * Vt * lt, y: t === 0 ? 0 : Math.log(Math.tan(Math.PI / 4 + t * Vt / 2)) * lt }), j = (s, t) => ({ lng: s === 0 ? 0 : At * (s / lt), lat: t === 0 ? 0 : (2 * Math.atan(Math.exp(t / lt)) - Math.PI / 2) * At });
|
|
696
696
|
function Se(s, t, e) {
|
|
697
697
|
const i = w(s[0]), o = w(s[1]), n = w(e), r = ee(t), a = Math.asin(Math.sin(o) * Math.cos(r) + Math.cos(o) * Math.sin(r) * Math.cos(n));
|
|
698
|
-
return [
|
|
698
|
+
return [T(i + Math.atan2(Math.sin(n) * Math.sin(r) * Math.cos(o), Math.cos(r) - Math.sin(o) * Math.sin(a))), T(a)];
|
|
699
699
|
}
|
|
700
700
|
function Rt(s) {
|
|
701
701
|
const { center: t, radiusKilometers: e, coordinatePrecision: i } = s, o = s.steps ? s.steps : 64, n = [];
|
|
@@ -958,17 +958,17 @@ class se extends D {
|
|
|
958
958
|
}), n.coord;
|
|
959
959
|
}
|
|
960
960
|
}
|
|
961
|
-
function
|
|
961
|
+
function Xt(s, t, e) {
|
|
962
962
|
const i = w(s[0]), o = w(s[1]), n = w(e), r = ee(t), a = Math.asin(Math.sin(o) * Math.cos(r) + Math.cos(o) * Math.sin(r) * Math.cos(n));
|
|
963
|
-
return [
|
|
963
|
+
return [T(i + Math.atan2(Math.sin(n) * Math.sin(r) * Math.cos(o), Math.cos(r) - Math.sin(o) * Math.sin(a))), T(a)];
|
|
964
964
|
}
|
|
965
|
-
function
|
|
965
|
+
function Tt({ x: s, y: t }, e, i) {
|
|
966
966
|
const o = w(i);
|
|
967
967
|
return { x: s + e * Math.cos(o), y: t + e * Math.sin(o) };
|
|
968
968
|
}
|
|
969
969
|
function Kt(s, t) {
|
|
970
970
|
const e = w(s[0]), i = w(t[0]), o = w(s[1]), n = w(t[1]), r = Math.sin(i - e) * Math.cos(n), a = Math.cos(o) * Math.sin(n) - Math.sin(o) * Math.cos(n) * Math.cos(i - e);
|
|
971
|
-
return
|
|
971
|
+
return T(Math.atan2(r, a));
|
|
972
972
|
}
|
|
973
973
|
function ht({ x: s, y: t }, { x: e, y: i }) {
|
|
974
974
|
let o = Math.atan2(i - t, e - s);
|
|
@@ -980,9 +980,9 @@ function De(s, t, e) {
|
|
|
980
980
|
for (let h = 0; h < s.length && !(t >= l && h === s.length - 1); h++) {
|
|
981
981
|
if (l > t && i.length === 0) {
|
|
982
982
|
if (n = t - l, !n) return i.push(s[h]), i;
|
|
983
|
-
r = Kt(s[h], s[h - 1]) - 180, a =
|
|
983
|
+
r = Kt(s[h], s[h - 1]) - 180, a = Xt(s[h], n, r), i.push(a);
|
|
984
984
|
}
|
|
985
|
-
if (l >= e) return n = e - l, n ? (r = Kt(s[h], s[h - 1]) - 180, a =
|
|
985
|
+
if (l >= e) return n = e - l, n ? (r = Kt(s[h], s[h - 1]) - 180, a = Xt(s[h], n, r), i.push(a), i) : (i.push(s[h]), i);
|
|
986
986
|
if (l >= t && i.push(s[h]), h === s.length - 1) return i;
|
|
987
987
|
l += W(s[h], s[h + 1]);
|
|
988
988
|
}
|
|
@@ -1039,7 +1039,7 @@ class Fe extends D {
|
|
|
1039
1039
|
function $(s, t) {
|
|
1040
1040
|
return s[0] === t[0] && s[1] === t[1];
|
|
1041
1041
|
}
|
|
1042
|
-
class
|
|
1042
|
+
class Oe extends O {
|
|
1043
1043
|
constructor(t) {
|
|
1044
1044
|
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;
|
|
1045
1045
|
const e = { start: "crosshair", close: "pointer" };
|
|
@@ -1153,7 +1153,7 @@ class ke extends O {
|
|
|
1153
1153
|
function ne(s, t) {
|
|
1154
1154
|
return s.geometry.type === "Point" && gt(s.geometry.coordinates, t);
|
|
1155
1155
|
}
|
|
1156
|
-
class
|
|
1156
|
+
class ke extends O {
|
|
1157
1157
|
constructor(t) {
|
|
1158
1158
|
super(t), this.mode = "point", this.cursors = void 0;
|
|
1159
1159
|
const e = { create: "crosshair" };
|
|
@@ -1431,7 +1431,7 @@ function dt(s, t) {
|
|
|
1431
1431
|
const e = s, i = t, o = w(e[1]), n = w(i[1]);
|
|
1432
1432
|
let r = w(i[0] - e[0]);
|
|
1433
1433
|
r > Math.PI && (r -= 2 * Math.PI), r < -Math.PI && (r += 2 * Math.PI);
|
|
1434
|
-
const a = Math.log(Math.tan(n / 2 + Math.PI / 4) / Math.tan(o / 2 + Math.PI / 4)), l = (
|
|
1434
|
+
const a = Math.log(Math.tan(n / 2 + Math.PI / 4) / Math.tan(o / 2 + Math.PI / 4)), l = (T(Math.atan2(r, a)) + 360) % 360;
|
|
1435
1435
|
return l > 180 ? -(360 - l) : l;
|
|
1436
1436
|
}
|
|
1437
1437
|
function Et(s, t, e) {
|
|
@@ -1675,7 +1675,7 @@ function ut(s) {
|
|
|
1675
1675
|
return { x: o / i, y: n / i };
|
|
1676
1676
|
}(t);
|
|
1677
1677
|
}
|
|
1678
|
-
class
|
|
1678
|
+
class Xe extends D {
|
|
1679
1679
|
constructor(t, e, i) {
|
|
1680
1680
|
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;
|
|
1681
1681
|
}
|
|
@@ -1718,7 +1718,7 @@ class Te extends D {
|
|
|
1718
1718
|
this.store.updateGeometry([{ id: e, geometry: o }, ...h, ...d]), this.projection === "web-mercator" ? this.lastBearing = r : this.projection === "globe" && (this.lastBearing = r + 180);
|
|
1719
1719
|
}
|
|
1720
1720
|
}
|
|
1721
|
-
class
|
|
1721
|
+
class Te extends D {
|
|
1722
1722
|
constructor(t, e, i) {
|
|
1723
1723
|
super(t), this.config = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.lastDistance = void 0, this.config = t, this.selectionPoints = e, this.midPoints = i;
|
|
1724
1724
|
}
|
|
@@ -1947,7 +1947,7 @@ class Ye extends Ee {
|
|
|
1947
1947
|
this._state = "selecting";
|
|
1948
1948
|
}
|
|
1949
1949
|
registerBehaviors(t) {
|
|
1950
|
-
this.pixelDistance = new pt(t), this.clickBoundingBox = new bt(t), this.featuresAtMouseEvent = new Ve(t, this.clickBoundingBox, this.pixelDistance), this.selectionPoints = new Ae(t), this.midPoints = new Ge(t, this.selectionPoints), this.rotateFeature = new
|
|
1950
|
+
this.pixelDistance = new pt(t), this.clickBoundingBox = new bt(t), this.featuresAtMouseEvent = new Ve(t, this.clickBoundingBox, this.pixelDistance), this.selectionPoints = new Ae(t), this.midPoints = new Ge(t, this.selectionPoints), this.rotateFeature = new Xe(t, this.selectionPoints, this.midPoints), this.scaleFeature = new Te(t, this.selectionPoints, this.midPoints), this.dragFeature = new Re(t, this.featuresAtMouseEvent, this.selectionPoints, this.midPoints), this.dragCoordinate = new Ue(t, this.pixelDistance, this.selectionPoints, this.midPoints), this.dragCoordinateResizeFeature = new Ke(t, this.pixelDistance, this.selectionPoints, this.midPoints);
|
|
1951
1951
|
}
|
|
1952
1952
|
deselectFeature() {
|
|
1953
1953
|
this.deselect();
|
|
@@ -2525,7 +2525,7 @@ class ii extends O {
|
|
|
2525
2525
|
const o = e[0], n = e[1], r = re(o, n, this.coordinatePrecision, this.project, this.unproject), a = P(o[0], o[1]), l = P(r[0], r[1]), d = P(n[0], n[1]), h = P(t.lng, t.lat), c = I(h, a) < I(h, d), u = $t(a, l, h), g = c ? 90 - u : $t(a, l, h) - 90, p = I(l, h), y = Math.cos(w(g)) * p, v = ht(a, d) + (function(_, S, F) {
|
|
2526
2526
|
const B = (F.x - S.x) * (_.y - S.y) - (F.y - S.y) * (_.x - S.x);
|
|
2527
2527
|
return B > 1e-10 ? "left" : B < -1e-10 ? "right" : "left";
|
|
2528
|
-
}(a, d, h) === "right" ? -90 : 90), m =
|
|
2528
|
+
}(a, d, h) === "right" ? -90 : 90), m = Tt(a, y, v), x = Tt(d, y, v), M = j(m.x, m.y), E = j(x.x, x.y);
|
|
2529
2529
|
i = [e[0], e[1], [E.lng, E.lat], [M.lng, M.lat], e[0]];
|
|
2530
2530
|
}
|
|
2531
2531
|
i && this.updatePolygonGeometry(this.currentId, i, C.Provisional);
|
|
@@ -2740,109 +2740,112 @@ class oi {
|
|
|
2740
2740
|
}
|
|
2741
2741
|
}
|
|
2742
2742
|
const si = {
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2743
|
+
modes: [
|
|
2744
|
+
"point",
|
|
2745
|
+
"linestring",
|
|
2746
|
+
"polygon",
|
|
2747
|
+
"rectangle",
|
|
2748
|
+
"angled-rectangle",
|
|
2749
|
+
"circle",
|
|
2750
|
+
"freehand",
|
|
2751
|
+
"select"
|
|
2752
|
+
],
|
|
2751
2753
|
open: !1
|
|
2752
|
-
}, ni = (
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2754
|
+
}, ni = () => ({
|
|
2755
|
+
render: new Be({
|
|
2756
|
+
modeName: "render",
|
|
2757
|
+
styles: {}
|
|
2758
|
+
}),
|
|
2759
|
+
point: new ke(),
|
|
2760
|
+
linestring: new Oe(),
|
|
2761
|
+
polygon: new Le({
|
|
2762
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
2763
|
+
// @ts-ignore
|
|
2764
|
+
validation: (t, e) => {
|
|
2765
|
+
const i = e.updateType;
|
|
2766
|
+
return i === "finish" || i === "commit" ? ei(t) : !0;
|
|
2767
|
+
}
|
|
2768
|
+
}),
|
|
2769
|
+
rectangle: new We(),
|
|
2770
|
+
"angled-rectangle": new ii(),
|
|
2771
|
+
circle: new we(),
|
|
2772
|
+
freehand: new Ie(),
|
|
2773
|
+
select: new Ye({
|
|
2774
|
+
flags: {
|
|
2775
|
+
point: {
|
|
2776
|
+
feature: {
|
|
2777
|
+
draggable: !0
|
|
2778
|
+
}
|
|
2779
|
+
},
|
|
2780
|
+
polygon: {
|
|
2781
|
+
feature: {
|
|
2782
|
+
draggable: !0,
|
|
2783
|
+
rotateable: !0,
|
|
2784
|
+
scaleable: !0,
|
|
2785
|
+
coordinates: {
|
|
2786
|
+
midpoints: !0,
|
|
2778
2787
|
draggable: !0,
|
|
2779
|
-
|
|
2780
|
-
scaleable: !0,
|
|
2781
|
-
coordinates: {
|
|
2782
|
-
midpoints: !0,
|
|
2783
|
-
draggable: !0,
|
|
2784
|
-
deletable: !0
|
|
2785
|
-
}
|
|
2788
|
+
deletable: !0
|
|
2786
2789
|
}
|
|
2787
|
-
}
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
+
}
|
|
2791
|
+
},
|
|
2792
|
+
linestring: {
|
|
2793
|
+
feature: {
|
|
2794
|
+
draggable: !0,
|
|
2795
|
+
coordinates: {
|
|
2796
|
+
midpoints: !0,
|
|
2790
2797
|
draggable: !0,
|
|
2791
|
-
|
|
2792
|
-
midpoints: !0,
|
|
2793
|
-
draggable: !0,
|
|
2794
|
-
deletable: !0
|
|
2795
|
-
}
|
|
2798
|
+
deletable: !0
|
|
2796
2799
|
}
|
|
2797
|
-
}
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
+
}
|
|
2801
|
+
},
|
|
2802
|
+
freehand: {
|
|
2803
|
+
feature: {
|
|
2804
|
+
draggable: !0,
|
|
2805
|
+
coordinates: {
|
|
2806
|
+
midpoints: !0,
|
|
2800
2807
|
draggable: !0,
|
|
2801
|
-
|
|
2802
|
-
midpoints: !0,
|
|
2803
|
-
draggable: !0,
|
|
2804
|
-
deletable: !0
|
|
2805
|
-
}
|
|
2808
|
+
deletable: !0
|
|
2806
2809
|
}
|
|
2807
|
-
}
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
+
}
|
|
2811
|
+
},
|
|
2812
|
+
circle: {
|
|
2813
|
+
feature: {
|
|
2814
|
+
draggable: !0,
|
|
2815
|
+
coordinates: {
|
|
2816
|
+
midpoints: !0,
|
|
2810
2817
|
draggable: !0,
|
|
2811
|
-
|
|
2812
|
-
midpoints: !0,
|
|
2813
|
-
draggable: !0,
|
|
2814
|
-
deletable: !0
|
|
2815
|
-
}
|
|
2818
|
+
deletable: !0
|
|
2816
2819
|
}
|
|
2817
|
-
}
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
+
}
|
|
2821
|
+
},
|
|
2822
|
+
rectangle: {
|
|
2823
|
+
feature: {
|
|
2824
|
+
draggable: !0,
|
|
2825
|
+
rotateable: !0,
|
|
2826
|
+
scaleable: !0,
|
|
2827
|
+
coordinates: {
|
|
2828
|
+
midpoints: !0,
|
|
2820
2829
|
draggable: !0,
|
|
2821
|
-
|
|
2822
|
-
scaleable: !0,
|
|
2823
|
-
coordinates: {
|
|
2824
|
-
midpoints: !0,
|
|
2825
|
-
draggable: !0,
|
|
2826
|
-
deletable: !0
|
|
2827
|
-
}
|
|
2830
|
+
deletable: !0
|
|
2828
2831
|
}
|
|
2829
|
-
}
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
+
}
|
|
2833
|
+
},
|
|
2834
|
+
"angled-rectangle": {
|
|
2835
|
+
feature: {
|
|
2836
|
+
draggable: !0,
|
|
2837
|
+
rotateable: !0,
|
|
2838
|
+
scaleable: !0,
|
|
2839
|
+
coordinates: {
|
|
2840
|
+
midpoints: !0,
|
|
2832
2841
|
draggable: !0,
|
|
2833
|
-
|
|
2834
|
-
scaleable: !0,
|
|
2835
|
-
coordinates: {
|
|
2836
|
-
midpoints: !0,
|
|
2837
|
-
draggable: !0,
|
|
2838
|
-
deletable: !0
|
|
2839
|
-
}
|
|
2842
|
+
deletable: !0
|
|
2840
2843
|
}
|
|
2841
2844
|
}
|
|
2842
2845
|
}
|
|
2843
|
-
}
|
|
2844
|
-
)
|
|
2845
|
-
};
|
|
2846
|
+
}
|
|
2847
|
+
})
|
|
2848
|
+
});
|
|
2846
2849
|
class ai {
|
|
2847
2850
|
/**
|
|
2848
2851
|
* Constructor
|
|
@@ -2855,29 +2858,43 @@ class ai {
|
|
|
2855
2858
|
k(this, "modeButtons", {});
|
|
2856
2859
|
k(this, "deleteButton");
|
|
2857
2860
|
k(this, "isExpanded", !1);
|
|
2858
|
-
k(this, "activeMode");
|
|
2859
2861
|
k(this, "terradraw");
|
|
2860
2862
|
k(this, "options", si);
|
|
2861
|
-
this.modeButtons = {},
|
|
2863
|
+
this.modeButtons = {}, t && (this.options = Object.assign(this.options, t));
|
|
2862
2864
|
}
|
|
2863
2865
|
getDefaultPosition() {
|
|
2864
2866
|
return "top-right";
|
|
2865
2867
|
}
|
|
2866
2868
|
onAdd(t) {
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
if (e.length === 0)
|
|
2869
|
+
var o, n;
|
|
2870
|
+
if (this.options && this.options.modes && this.options.modes.length === 0)
|
|
2870
2871
|
throw new Error("At least a mode must be enabled.");
|
|
2871
|
-
|
|
2872
|
+
this.map = t;
|
|
2873
|
+
const e = ni(), i = [e.render];
|
|
2874
|
+
return (n = (o = this.options) == null ? void 0 : o.modes) == null || n.forEach((r) => {
|
|
2875
|
+
if (this.options.modeOptions && this.options.modeOptions[r]) {
|
|
2876
|
+
const a = this.options.modeOptions[r];
|
|
2877
|
+
if (r === "select") {
|
|
2878
|
+
const l = e[r];
|
|
2879
|
+
if (l) {
|
|
2880
|
+
const d = l.flags;
|
|
2881
|
+
Object.keys(d).forEach((h) => {
|
|
2882
|
+
a.flags[h] || (a.flags[h] = d[h]);
|
|
2883
|
+
});
|
|
2884
|
+
}
|
|
2885
|
+
}
|
|
2886
|
+
i.push(a);
|
|
2887
|
+
} else e[r] && i.push(e[r]);
|
|
2888
|
+
}), this.isExpanded = this.options.open === !0, this.terradraw = new oi({
|
|
2872
2889
|
adapter: new pe({ map: t }),
|
|
2873
|
-
modes:
|
|
2874
|
-
}), this.terradraw.start(), this.controlContainer = document.createElement("div"), this.controlContainer.classList.add("maplibregl-ctrl"), this.controlContainer.classList.add("maplibregl-ctrl-group"), this.addButton = document.createElement("button"), this.addButton.classList.add("maplibregl-terradraw-add-button"), this.isExpanded && this.addButton.classList.add("enabled"), this.addButton.type = "button", this.addButton.addEventListener("click", this.toggleEditor.bind(this)),
|
|
2875
|
-
|
|
2890
|
+
modes: i
|
|
2891
|
+
}), this.terradraw.start(), this.controlContainer = document.createElement("div"), this.controlContainer.classList.add("maplibregl-ctrl"), this.controlContainer.classList.add("maplibregl-ctrl-group"), this.addButton = document.createElement("button"), this.addButton.classList.add("maplibregl-terradraw-add-button"), this.isExpanded && this.addButton.classList.add("enabled"), this.addButton.type = "button", this.addButton.addEventListener("click", this.toggleEditor.bind(this)), i.forEach((r) => {
|
|
2892
|
+
r.mode !== "render" && this.addTerradrawButton(r.mode);
|
|
2876
2893
|
}), this.deleteButton = document.createElement("button"), this.deleteButton.classList.add("maplibregl-terradraw-add-control"), this.deleteButton.classList.add("maplibregl-terradraw-delete-button"), this.isExpanded || this.deleteButton.classList.add("hidden"), this.deleteButton.type = "button", this.deleteButton.addEventListener("click", () => {
|
|
2877
2894
|
this.terradraw && this.terradraw.enabled && (this.terradraw.clear(), this.deactivate());
|
|
2878
|
-
}), this.controlContainer.appendChild(this.addButton), Object.values(this.modeButtons).forEach((
|
|
2879
|
-
var
|
|
2880
|
-
(
|
|
2895
|
+
}), this.controlContainer.appendChild(this.addButton), Object.values(this.modeButtons).forEach((r) => {
|
|
2896
|
+
var a;
|
|
2897
|
+
(a = this.controlContainer) == null || a.appendChild(r);
|
|
2881
2898
|
}), this.controlContainer.appendChild(this.deleteButton), this.controlContainer;
|
|
2882
2899
|
}
|
|
2883
2900
|
onRemove() {
|
|
@@ -2928,7 +2945,7 @@ class ai {
|
|
|
2928
2945
|
const o = t.item(i);
|
|
2929
2946
|
o && o.classList.remove("active");
|
|
2930
2947
|
}
|
|
2931
|
-
|
|
2948
|
+
(e = this.terradraw) == null || e.setMode("render");
|
|
2932
2949
|
}
|
|
2933
2950
|
/**
|
|
2934
2951
|
* Add Terra Draw drawing mode button
|
|
@@ -2939,7 +2956,7 @@ class ai {
|
|
|
2939
2956
|
e.classList.add("maplibregl-terradraw-add-control"), e.classList.add(`maplibregl-terradraw-add-${t}-button`), this.isExpanded || e.classList.add("hidden"), e.type = "button", e.addEventListener("click", () => {
|
|
2940
2957
|
if (!this.terradraw) return;
|
|
2941
2958
|
const i = e.classList.contains("active");
|
|
2942
|
-
this.activate(), this.resetActiveMode(), i || (this.terradraw.setMode(t),
|
|
2959
|
+
this.activate(), this.resetActiveMode(), i || (this.terradraw.setMode(t), e.classList.add("active"));
|
|
2943
2960
|
}), this.modeButtons[t] = e;
|
|
2944
2961
|
}
|
|
2945
2962
|
}
|