@nextgis/leaflet-map-adapter 2.1.0 → 2.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.
@@ -1,4 +1,4 @@
1
- /** Bundle of @nextgis/leaflet-map-adapter; version: 2.1.0; author: NextGIS */
1
+ /** Bundle of @nextgis/leaflet-map-adapter; version: 2.2.0; author: NextGIS */
2
2
  var domain;
3
3
 
4
4
  // This constructor is used to store event handlers. Instantiating this is
@@ -15685,30 +15685,32 @@ var __publicField$3 = (obj, key, value) => {
15685
15685
  class ImageOverlay extends leafletSrcExports.ImageOverlay {
15686
15686
  constructor(imageUrl, bounds, options) {
15687
15687
  super(imageUrl, bounds, options);
15688
- __publicField$3(this, "_abort", []);
15688
+ __publicField$3(this, "_aborter");
15689
15689
  }
15690
15690
  cancelLoad() {
15691
- if (this._abort) {
15692
- this._abort.forEach((x) => x());
15693
- this._abort = [];
15691
+ if (this._aborter) {
15692
+ this._aborter();
15693
+ this._aborter = void 0;
15694
15694
  }
15695
15695
  }
15696
15696
  _initImage() {
15697
15697
  super._initImage();
15698
15698
  const headers = this.options.headers;
15699
+ const img = this._image;
15700
+ const src = img.src;
15699
15701
  if (headers) {
15700
- const img = this._image;
15701
- const src = img.src;
15702
15702
  img.src = "";
15703
- this._abort.push(
15704
- callAjax(
15705
- src,
15706
- (response) => {
15707
- img.src = response;
15708
- },
15709
- headers
15710
- )
15703
+ this._aborter = callAjax(
15704
+ src,
15705
+ (response) => {
15706
+ img.src = response;
15707
+ },
15708
+ headers
15711
15709
  );
15710
+ } else {
15711
+ this._aborter = () => {
15712
+ img.setAttribute("src", leafletSrcExports.Util.emptyImageUrl);
15713
+ };
15712
15714
  }
15713
15715
  }
15714
15716
  }
@@ -15747,6 +15749,7 @@ class ImageLayer extends leafletSrcExports.Layer {
15747
15749
  __publicField$2(this, "_url");
15748
15750
  __publicField$2(this, "_currentUrl");
15749
15751
  __publicField$2(this, "_currentOverlay");
15752
+ __publicField$2(this, "_loadedOverlay");
15750
15753
  this._url = url;
15751
15754
  const params = {};
15752
15755
  const opts = {};
@@ -15800,15 +15803,18 @@ class ImageLayer extends leafletSrcExports.Layer {
15800
15803
  this._currentUrl = url;
15801
15804
  const viewPortBuffer = this.options.viewPortBuffer || 0;
15802
15805
  const bounds = this._map.getBounds().pad(viewPortBuffer);
15806
+ if (this._loadedOverlay) {
15807
+ this._loadedOverlay.cancelLoad();
15808
+ this._loadedOverlay.off("load");
15809
+ this._loadedOverlay = void 0;
15810
+ }
15803
15811
  const overlay = new ImageOverlay(url, bounds, {
15804
15812
  opacity: 0,
15805
15813
  pane: this.options.pane,
15806
15814
  headers: this.options.headers
15807
15815
  });
15808
15816
  overlay.addTo(this._map);
15809
- if (this._currentOverlay) {
15810
- this._currentOverlay.cancelLoad();
15811
- }
15817
+ this._loadedOverlay = overlay;
15812
15818
  overlay.once(
15813
15819
  "load",
15814
15820
  () => {
@@ -15821,6 +15827,7 @@ class ImageLayer extends leafletSrcExports.Layer {
15821
15827
  } else if (this._currentOverlay) {
15822
15828
  this._map.removeLayer(this._currentOverlay);
15823
15829
  }
15830
+ this._loadedOverlay = void 0;
15824
15831
  this._currentOverlay = overlay;
15825
15832
  overlay.setOpacity(
15826
15833
  this.options.opacity !== void 0 ? this.options.opacity : 1