mapboxgl-tools 2.2.10 → 2.2.12

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
@@ -2471,6 +2471,7 @@ class MeasureDistanceControl extends KeyboardControl {
2471
2471
  }
2472
2472
  }
2473
2473
  var control$4 = "";
2474
+ const areaPath = "M146.285714 292.571429v438.857142h73.142857V292.571429zM804.571429 292.571429v438.857142h73.142857V292.571429zM292.571429 219.428571h438.857142V146.285714H292.571429zM292.571429 877.714286h438.857142v-73.142857H292.571429zM345.234286 397.897143l292.571428 292.571428a36.571429 36.571429 0 1 0 51.712-51.712l-292.571428-292.571428a36.571429 36.571429 0 0 0-51.712 51.712zM804.571429 804.571429h73.142857v73.142857h-73.142857v-73.142857z m146.285714-73.142858h-219.428572v219.428572h219.428572v-219.428572zM804.571429 146.285714h73.142857v73.142857h-73.142857V146.285714z m146.285714-73.142857h-219.428572v219.428572h219.428572V73.142857zM146.285714 146.285714h73.142857v73.142857H146.285714V146.285714z m146.285715-73.142857H73.142857v219.428572h219.428572V73.142857zM146.285714 804.571429h73.142857v73.142857H146.285714v-73.142857z m146.285715-73.142858H73.142857v219.428572h219.428572v-219.428572z";
2474
2475
  const options$4 = {
2475
2476
  title: "\u6D4B\u91CF\u9762\u79EF",
2476
2477
  showCloseButton: true,
@@ -2489,7 +2490,8 @@ const options$4 = {
2489
2490
  fillOpacity: 0.1,
2490
2491
  lineColor: "#ff0000",
2491
2492
  lineWidth: 2,
2492
- lineOpacity: 0.65
2493
+ lineOpacity: 0.65,
2494
+ isKeep: true
2493
2495
  };
2494
2496
  const WBK_AREA_SOURCE_POINTS = "WBK_AREA_SOURCE_POINTS";
2495
2497
  const WBK_AREA_SOURCE_LINE = "WBK_AREA_SOURCE_LINE";
@@ -2626,6 +2628,7 @@ class MeasureAreaControl extends KeyboardControl {
2626
2628
  this._map.on("dblclick", (e2) => {
2627
2629
  if (!this.flag)
2628
2630
  return;
2631
+ e2.preventDefault();
2629
2632
  const coords = [e2.lngLat.lng, e2.lngLat.lat];
2630
2633
  this.points.push(coords);
2631
2634
  this.measureFlag = false;
@@ -2638,23 +2641,33 @@ class MeasureAreaControl extends KeyboardControl {
2638
2641
  this.startEle.style.display = "none";
2639
2642
  }
2640
2643
  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
2644
  const wkt = `POLYGON((${this.points.map((p2) => `${p2[0]} ${p2[1]}`).join(", ")}, ${this.points[0][0]} ${this.points[0][1]}))`;
2645
+ if (!this.options.isKeep) {
2646
+ this._clearLayers();
2647
+ this._resetData();
2648
+ this.measureFlag = false;
2649
+ this._map.doubleClickZoom.enable();
2650
+ this._map.getCanvas().style.cursor = "";
2651
+ this._onClose();
2652
+ this._container.querySelector(`.${this.mainClass}-entry path`).setAttribute("d", areaPath);
2653
+ } else {
2654
+ if (this.options.showCloseButton) {
2655
+ const ele = document.createElement("div");
2656
+ ele.setAttribute("class", `${this.mainClass}-result wbiokr-ctrl-close`);
2657
+ const option = {
2658
+ element: ele,
2659
+ anchor: "left",
2660
+ offset: this.options.showArea ? [60, 0] : [15, 0]
2661
+ };
2662
+ ele.innerHTML = "\xD7";
2663
+ this.closeButtonMarker = new mapboxgl.Marker(option).setLngLat(coords).addTo(this._map);
2664
+ const self2 = this;
2665
+ ele.onclick = function(__e) {
2666
+ __e.stopPropagation();
2667
+ self2._close();
2668
+ }.bind(this);
2669
+ }
2670
+ }
2658
2671
  this.options.onEnd && this.options.onEnd({ area: area2, coords, wkt });
2659
2672
  });
2660
2673
  this._map.on("mousemove", (e2) => {
@@ -2889,7 +2902,8 @@ const options$2 = {
2889
2902
  fillColor: "#f00",
2890
2903
  fillOpacity: 0.4,
2891
2904
  lineColor: "#f00",
2892
- lineWidth: 2
2905
+ lineWidth: 2,
2906
+ isKeep: true
2893
2907
  };
2894
2908
  class MouseRectControl extends KeyboardControl {
2895
2909
  constructor(e2) {
@@ -2954,8 +2968,15 @@ class MouseRectControl extends KeyboardControl {
2954
2968
  this.moving = false;
2955
2969
  const wkt = `POLYGON((${minX} ${minY}, ${minX} ${maxY}, ${maxX} ${maxY}, ${maxX} ${minY}, ${minX} ${minY}))`;
2956
2970
  this.options.onEnd && this.options.onEnd({ minX, minY, maxX, maxY, wkt });
2957
- if (this.options.showCloseButton) {
2958
- this._addCloseButton([maxX, maxY]);
2971
+ if (!this.options.isKeep) {
2972
+ this._clearDrawLayers();
2973
+ this.flagValue = false;
2974
+ this._onClose();
2975
+ this._container.querySelector(`.${this.mainClass}-entry path`).setAttribute("d", rectPath);
2976
+ } else {
2977
+ if (this.options.showCloseButton) {
2978
+ this._addCloseButton([maxX, maxY]);
2979
+ }
2959
2980
  }
2960
2981
  }
2961
2982
  });
@@ -3055,6 +3076,21 @@ class MouseRectControl extends KeyboardControl {
3055
3076
  this.endLoc = [];
3056
3077
  this.locs = [];
3057
3078
  }
3079
+ _clearDrawLayers() {
3080
+ if (this._map.getLayer(LAYER_WBK_RECT_FILL)) {
3081
+ this._map.removeLayer(LAYER_WBK_RECT_FILL);
3082
+ }
3083
+ if (this._map.getLayer(LAYER_WBK_RECT_LINE)) {
3084
+ this._map.removeLayer(LAYER_WBK_RECT_LINE);
3085
+ }
3086
+ if (this._map.getSource(SOURCE_WBK_RECT)) {
3087
+ this._map.removeSource(SOURCE_WBK_RECT);
3088
+ }
3089
+ if (this.closeButtonMarker) {
3090
+ this.closeButtonMarker.remove();
3091
+ this.closeButtonMarker = null;
3092
+ }
3093
+ }
3058
3094
  _addCloseButton(coords) {
3059
3095
  const ele = document.createElement("div");
3060
3096
  ele.setAttribute("class", `${this.mainClass}-result wbiokr-ctrl-close`);