mapboxgl-tools 2.2.10 → 2.2.11

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/ui.es.js CHANGED
@@ -2489,7 +2489,8 @@ const options$4 = {
2489
2489
  fillOpacity: 0.1,
2490
2490
  lineColor: "#ff0000",
2491
2491
  lineWidth: 2,
2492
- lineOpacity: 0.65
2492
+ lineOpacity: 0.65,
2493
+ isKeep: true
2493
2494
  };
2494
2495
  const WBK_AREA_SOURCE_POINTS = "WBK_AREA_SOURCE_POINTS";
2495
2496
  const WBK_AREA_SOURCE_LINE = "WBK_AREA_SOURCE_LINE";
@@ -2638,23 +2639,28 @@ class MeasureAreaControl extends KeyboardControl {
2638
2639
  this.startEle.style.display = "none";
2639
2640
  }
2640
2641
  this.tooltip.setLngLat(coords);
2641
- if (this.options.showCloseButton) {
2642
- const ele = document.createElement("div");
2643
- ele.setAttribute("class", `${this.mainClass}-result wbiokr-ctrl-close`);
2644
- const option = {
2645
- element: ele,
2646
- anchor: "left",
2647
- offset: this.options.showArea ? [60, 0] : [15, 0]
2648
- };
2649
- ele.innerHTML = "\xD7";
2650
- this.closeButtonMarker = new mapboxgl.Marker(option).setLngLat(coords).addTo(this._map);
2651
- const self2 = this;
2652
- ele.onclick = function(__e) {
2653
- __e.stopPropagation();
2654
- self2._close();
2655
- }.bind(this);
2656
- }
2657
2642
  const wkt = `POLYGON((${this.points.map((p2) => `${p2[0]} ${p2[1]}`).join(", ")}, ${this.points[0][0]} ${this.points[0][1]}))`;
2643
+ if (!this.options.isKeep) {
2644
+ this._clearLayers();
2645
+ this._resetData();
2646
+ } else {
2647
+ if (this.options.showCloseButton) {
2648
+ const ele = document.createElement("div");
2649
+ ele.setAttribute("class", `${this.mainClass}-result wbiokr-ctrl-close`);
2650
+ const option = {
2651
+ element: ele,
2652
+ anchor: "left",
2653
+ offset: this.options.showArea ? [60, 0] : [15, 0]
2654
+ };
2655
+ ele.innerHTML = "\xD7";
2656
+ this.closeButtonMarker = new mapboxgl.Marker(option).setLngLat(coords).addTo(this._map);
2657
+ const self2 = this;
2658
+ ele.onclick = function(__e) {
2659
+ __e.stopPropagation();
2660
+ self2._close();
2661
+ }.bind(this);
2662
+ }
2663
+ }
2658
2664
  this.options.onEnd && this.options.onEnd({ area: area2, coords, wkt });
2659
2665
  });
2660
2666
  this._map.on("mousemove", (e2) => {
@@ -2889,7 +2895,8 @@ const options$2 = {
2889
2895
  fillColor: "#f00",
2890
2896
  fillOpacity: 0.4,
2891
2897
  lineColor: "#f00",
2892
- lineWidth: 2
2898
+ lineWidth: 2,
2899
+ isKeep: true
2893
2900
  };
2894
2901
  class MouseRectControl extends KeyboardControl {
2895
2902
  constructor(e2) {
@@ -2954,8 +2961,12 @@ class MouseRectControl extends KeyboardControl {
2954
2961
  this.moving = false;
2955
2962
  const wkt = `POLYGON((${minX} ${minY}, ${minX} ${maxY}, ${maxX} ${maxY}, ${maxX} ${minY}, ${minX} ${minY}))`;
2956
2963
  this.options.onEnd && this.options.onEnd({ minX, minY, maxX, maxY, wkt });
2957
- if (this.options.showCloseButton) {
2958
- this._addCloseButton([maxX, maxY]);
2964
+ if (!this.options.isKeep) {
2965
+ this._clearDrawLayers();
2966
+ } else {
2967
+ if (this.options.showCloseButton) {
2968
+ this._addCloseButton([maxX, maxY]);
2969
+ }
2959
2970
  }
2960
2971
  }
2961
2972
  });
@@ -3055,6 +3066,21 @@ class MouseRectControl extends KeyboardControl {
3055
3066
  this.endLoc = [];
3056
3067
  this.locs = [];
3057
3068
  }
3069
+ _clearDrawLayers() {
3070
+ if (this._map.getLayer(LAYER_WBK_RECT_FILL)) {
3071
+ this._map.removeLayer(LAYER_WBK_RECT_FILL);
3072
+ }
3073
+ if (this._map.getLayer(LAYER_WBK_RECT_LINE)) {
3074
+ this._map.removeLayer(LAYER_WBK_RECT_LINE);
3075
+ }
3076
+ if (this._map.getSource(SOURCE_WBK_RECT)) {
3077
+ this._map.removeSource(SOURCE_WBK_RECT);
3078
+ }
3079
+ if (this.closeButtonMarker) {
3080
+ this.closeButtonMarker.remove();
3081
+ this.closeButtonMarker = null;
3082
+ }
3083
+ }
3058
3084
  _addCloseButton(coords) {
3059
3085
  const ele = document.createElement("div");
3060
3086
  ele.setAttribute("class", `${this.mainClass}-result wbiokr-ctrl-close`);