@watergis/maplibre-gl-terradraw 0.6.2 → 0.6.3

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.
@@ -2753,6 +2753,8 @@ const vi = [
2753
2753
  "angled-rectangle",
2754
2754
  "sensor",
2755
2755
  "sector",
2756
+ "select",
2757
+ "delete-selection",
2756
2758
  "delete"
2757
2759
  ], oi = {
2758
2760
  modes: [
@@ -3593,12 +3595,17 @@ class xi extends ni {
3593
3595
  data: { type: "FeatureCollection", features: [] }
3594
3596
  }), this.map.getLayer(this.polygonLayerSpec.id) || this.map.addLayer(this.polygonLayerSpec)), e && e.length > 0 || i && i.length > 0) {
3595
3597
  const n = this.getTerraDrawInstance();
3596
- n && (n.on("finish", (a) => {
3598
+ n && (n.on("change", (a) => {
3597
3599
  if (!this.map) return;
3598
3600
  const l = this.getTerraDrawInstance();
3599
3601
  if (!l) return;
3600
- const c = l.getSnapshot(), d = (c == null ? void 0 : c.find((u) => u.id === a)).geometry.type;
3601
- d === "LineString" ? this.measureLine(a) : d === "Polygon" && this.measurePolygon(a);
3602
+ const c = l.getSnapshot();
3603
+ for (const h of a) {
3604
+ const d = c == null ? void 0 : c.find((p) => p.id === h);
3605
+ if (!d) continue;
3606
+ const u = d.geometry.type, g = d.properties.mode;
3607
+ g === "linestring" && u === "LineString" ? this.measureLine(h) : !["point", "linestring", "select", "render"].includes(g) && u === "Polygon" && this.measurePolygon(h);
3608
+ }
3602
3609
  }), this.on("feature-deleted", this.onFeatureDeleted.bind(this)));
3603
3610
  }
3604
3611
  }
@@ -3621,6 +3628,12 @@ class xi extends ni {
3621
3628
  if (r) {
3622
3629
  const a = this.map.getStyle().sources[this.polygonLayerSpec.source];
3623
3630
  if (a) {
3631
+ typeof a.data != "string" && a.data.type === "FeatureCollection" && (a.data.features = a.data.features.filter(
3632
+ (u) => {
3633
+ var g;
3634
+ return ((g = u.properties) == null ? void 0 : g.originalId) !== e;
3635
+ }
3636
+ ));
3624
3637
  const l = pi(r.geometry), c = JSON.parse(JSON.stringify(r));
3625
3638
  c.id = c.id + "-area-label", c.geometry = mi(r.geometry).geometry, c.properties.originalId = r.id;
3626
3639
  let h = l, d = "m2";
@@ -3644,6 +3657,12 @@ class xi extends ni {
3644
3657
  const a = this.map.getStyle().sources[this.lineLayerLabelSpec.source];
3645
3658
  if (a) {
3646
3659
  const l = r.geometry.coordinates;
3660
+ typeof a.data != "string" && a.data.type === "FeatureCollection" && (a.data.features = a.data.features.filter(
3661
+ (h) => {
3662
+ var d;
3663
+ return ((d = h.properties) == null ? void 0 : d.originalId) !== e;
3664
+ }
3665
+ ));
3647
3666
  let c = 0;
3648
3667
  for (let h = 0; h < l.length - 1; h++) {
3649
3668
  const d = l[h], u = l[h + 1], g = di(d, u, { units: "kilometers" });