@watergis/maplibre-gl-terradraw 0.1.0 → 0.1.2

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/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  [![CI](https://github.com/watergis/maplibre-gl-terradraw/actions/workflows/ci.yml/badge.svg)](https://github.com/watergis/maplibre-gl-terradraw/actions/workflows/ci.yml)
6
6
  [![Netlify Status](https://api.netlify.com/api/v1/badges/3486d35f-7a74-4c1c-a94a-6db0f7250583/deploy-status)](https://app.netlify.com/sites/maplibre-gl-terradraw/deploys)
7
7
 
8
- This plugin is to add controls to your MapLibre for sketching powered by [Terra Draw](https://github.com/JamesLMilner/terra-draw) library.
8
+ This plugin is to add controls to your MapLibre for drawing powered by [Terra Draw](https://github.com/JamesLMilner/terra-draw) library.
9
9
 
10
10
  ## Install
11
11
 
@@ -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")], kt = [-180, -90, 180, 90], _e = 6378137 * Math.PI / 180;
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: kt, axisOrientation: e, global: !0, metersPerUnit: _e, worldExtent: kt });
529
+ super({ code: t, units: "degrees", extent: Ot, axisOrientation: e, global: !0, metersPerUnit: _e, worldExtent: Ot });
530
530
  }
531
531
  }
532
- const Ot = [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")];
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,7 +553,7 @@ function jt(s) {
553
553
  });
554
554
  }
555
555
  var Lt, Wt, Bt, C;
556
- jt(Ft), jt(Ot), Lt = Ft, Wt = function(s, t, e) {
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) {
@@ -567,7 +567,7 @@ jt(Ft), jt(Ot), Lt = Ft, Wt = function(s, t, e) {
567
567
  e = e > 1 ? e : 2, t === void 0 && (t = e > 2 ? s.slice() : new Array(i));
568
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
- }, Ot.forEach(function(s) {
570
+ }, kt.forEach(function(s) {
571
571
  Lt.forEach(function(t) {
572
572
  at(s, t, Wt), at(t, s, Bt);
573
573
  });
@@ -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 ke extends O {
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 Oe extends O {
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" };
@@ -2756,8 +2756,8 @@ const si = {
2756
2756
  modeName: "render",
2757
2757
  styles: {}
2758
2758
  }),
2759
- point: new Oe(),
2760
- linestring: new ke(),
2759
+ point: new ke(),
2760
+ linestring: new Oe(),
2761
2761
  polygon: new Le({
2762
2762
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2763
2763
  // @ts-ignore
@@ -2792,6 +2792,8 @@ const si = {
2792
2792
  linestring: {
2793
2793
  feature: {
2794
2794
  draggable: !0,
2795
+ rotateable: !0,
2796
+ scaleable: !0,
2795
2797
  coordinates: {
2796
2798
  midpoints: !0,
2797
2799
  draggable: !0,
@@ -2850,21 +2852,17 @@ class ai {
2850
2852
  /**
2851
2853
  * Constructor
2852
2854
  * @param options Plugin control options
2853
- * @param modeOptions Overwrite Terra Draw mode options if you specified.
2854
- *
2855
2855
  */
2856
- constructor(t, e) {
2856
+ constructor(t) {
2857
2857
  k(this, "controlContainer");
2858
2858
  k(this, "map");
2859
2859
  k(this, "addButton");
2860
2860
  k(this, "modeButtons", {});
2861
2861
  k(this, "deleteButton");
2862
2862
  k(this, "isExpanded", !1);
2863
- k(this, "activeMode");
2864
2863
  k(this, "terradraw");
2865
2864
  k(this, "options", si);
2866
- k(this, "modeOptions");
2867
- this.modeButtons = {}, this.activeMode = "render", t && (this.options = Object.assign(this.options, t)), this.modeOptions = e;
2865
+ this.modeButtons = {}, t && (this.options = Object.assign(this.options, t));
2868
2866
  }
2869
2867
  getDefaultPosition() {
2870
2868
  return "top-right";
@@ -2876,7 +2874,19 @@ class ai {
2876
2874
  this.map = t;
2877
2875
  const e = ni(), i = [e.render];
2878
2876
  return (n = (o = this.options) == null ? void 0 : o.modes) == null || n.forEach((r) => {
2879
- this.modeOptions && this.modeOptions[r] ? i.push(this.modeOptions[r]) : e[r] && i.push(e[r]);
2877
+ if (this.options.modeOptions && this.options.modeOptions[r]) {
2878
+ const a = this.options.modeOptions[r];
2879
+ if (r === "select") {
2880
+ const l = e[r];
2881
+ if (l) {
2882
+ const d = l.flags;
2883
+ Object.keys(d).forEach((h) => {
2884
+ a.flags[h] || (a.flags[h] = d[h]);
2885
+ });
2886
+ }
2887
+ }
2888
+ i.push(a);
2889
+ } else e[r] && i.push(e[r]);
2880
2890
  }), this.isExpanded = this.options.open === !0, this.terradraw = new oi({
2881
2891
  adapter: new pe({ map: t }),
2882
2892
  modes: i
@@ -2937,7 +2947,7 @@ class ai {
2937
2947
  const o = t.item(i);
2938
2948
  o && o.classList.remove("active");
2939
2949
  }
2940
- this.activeMode = "render", (e = this.terradraw) == null || e.setMode("render");
2950
+ (e = this.terradraw) == null || e.setMode("render");
2941
2951
  }
2942
2952
  /**
2943
2953
  * Add Terra Draw drawing mode button
@@ -2948,7 +2958,7 @@ class ai {
2948
2958
  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", () => {
2949
2959
  if (!this.terradraw) return;
2950
2960
  const i = e.classList.contains("active");
2951
- this.activate(), this.resetActiveMode(), i || (this.terradraw.setMode(t), this.activeMode = t, e.classList.add("active"));
2961
+ this.activate(), this.resetActiveMode(), i || (this.terradraw.setMode(t), e.classList.add("active"));
2952
2962
  }), this.modeButtons[t] = e;
2953
2963
  }
2954
2964
  }