mapboxgl-tools 1.1.2 → 1.2.0

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
@@ -20908,6 +20908,8 @@ const options = {
20908
20908
  onOpen: () => {
20909
20909
  },
20910
20910
  onEnd: () => {
20911
+ },
20912
+ onMousemove: () => {
20911
20913
  }
20912
20914
  };
20913
20915
  class MouseRectControl {
@@ -20957,30 +20959,43 @@ class MouseRectControl {
20957
20959
  this.startLoc = newLoc;
20958
20960
  isStart = true;
20959
20961
  }
20962
+ const minX = Math.min(this.startLoc[0], this.endLoc[0]);
20963
+ const minY = Math.min(this.startLoc[1], this.endLoc[1]);
20964
+ const maxX = Math.max(this.startLoc[0], this.endLoc[0]);
20965
+ const maxY = Math.max(this.startLoc[1], this.endLoc[1]);
20966
+ if (!isStart) {
20967
+ this.moving = false;
20968
+ this.options.onEnd && this.options.onEnd({ minX, minY, maxX, maxY });
20969
+ }
20970
+ });
20971
+ this._map.on("mousemove", (e) => {
20972
+ if (!this.flag || !this.moving)
20973
+ return;
20974
+ if (!this.startLoc || this.startLoc.length === 0)
20975
+ return;
20976
+ const lngLat = e.lngLat;
20977
+ const newLoc = [lngLat.lng, lngLat.lat];
20960
20978
  this.endLoc = newLoc;
20961
20979
  const minX = Math.min(this.startLoc[0], this.endLoc[0]);
20962
20980
  const minY = Math.min(this.startLoc[1], this.endLoc[1]);
20963
20981
  const maxX = Math.max(this.startLoc[0], this.endLoc[0]);
20964
20982
  const maxY = Math.max(this.startLoc[1], this.endLoc[1]);
20965
- console.log(this.endLoc, this.startLoc);
20966
20983
  this._map.getSource(SOURCE_WBK_RECT).setData({
20967
20984
  type: "Feature",
20968
20985
  geometry: {
20969
20986
  type: "Polygon",
20970
20987
  coordinates: [
20971
- [minX, minY],
20972
- [minX, maxY],
20973
- [maxX, maxY],
20974
- [maxX, minY],
20975
- [minX, minY]
20988
+ [
20989
+ [minX, minY],
20990
+ [minX, maxY],
20991
+ [maxX, maxY],
20992
+ [maxX, minY],
20993
+ [minX, minY]
20994
+ ]
20976
20995
  ]
20977
20996
  }
20978
20997
  });
20979
- console.log(this._map.getSource(SOURCE_WBK_RECT), isStart);
20980
- if (!isStart) {
20981
- this.moving = false;
20982
- this.options.onEnd && this.options.onEnd({ minX, minY, maxX, maxY });
20983
- }
20998
+ this.options.onMousemove && this.options.onMousemove(e);
20984
20999
  });
20985
21000
  }
20986
21001
  _open() {
@@ -20992,11 +21007,8 @@ class MouseRectControl {
20992
21007
  this._map.addSource(SOURCE_WBK_RECT, {
20993
21008
  type: "geojson",
20994
21009
  data: {
20995
- type: "Feature",
20996
- geometry: {
20997
- type: "Polygon",
20998
- coordinates: []
20999
- }
21010
+ type: "FeatureCollection",
21011
+ features: []
21000
21012
  }
21001
21013
  });
21002
21014
  }