@nextgis/ngw-leaflet 2.1.1 → 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/ngw-leaflet; version: 2.1.1; author: NextGIS */
1
+ /** Bundle of @nextgis/ngw-leaflet; version: 2.2.0; author: NextGIS */
2
2
  function styleInject(css, ref) {
3
3
  if ( ref === void 0 ) ref = {};
4
4
  var insertAt = ref.insertAt;
@@ -16905,30 +16905,32 @@ var __publicField$D = (obj, key, value) => {
16905
16905
  class ImageOverlay extends leafletSrcExports.ImageOverlay {
16906
16906
  constructor(imageUrl, bounds, options) {
16907
16907
  super(imageUrl, bounds, options);
16908
- __publicField$D(this, "_abort", []);
16908
+ __publicField$D(this, "_aborter");
16909
16909
  }
16910
16910
  cancelLoad() {
16911
- if (this._abort) {
16912
- this._abort.forEach((x) => x());
16913
- this._abort = [];
16911
+ if (this._aborter) {
16912
+ this._aborter();
16913
+ this._aborter = void 0;
16914
16914
  }
16915
16915
  }
16916
16916
  _initImage() {
16917
16917
  super._initImage();
16918
16918
  const headers = this.options.headers;
16919
+ const img = this._image;
16920
+ const src = img.src;
16919
16921
  if (headers) {
16920
- const img = this._image;
16921
- const src = img.src;
16922
16922
  img.src = "";
16923
- this._abort.push(
16924
- callAjax(
16925
- src,
16926
- (response) => {
16927
- img.src = response;
16928
- },
16929
- headers
16930
- )
16923
+ this._aborter = callAjax(
16924
+ src,
16925
+ (response) => {
16926
+ img.src = response;
16927
+ },
16928
+ headers
16931
16929
  );
16930
+ } else {
16931
+ this._aborter = () => {
16932
+ img.setAttribute("src", leafletSrcExports.Util.emptyImageUrl);
16933
+ };
16932
16934
  }
16933
16935
  }
16934
16936
  }
@@ -16967,6 +16969,7 @@ class ImageLayer extends leafletSrcExports.Layer {
16967
16969
  __publicField$C(this, "_url");
16968
16970
  __publicField$C(this, "_currentUrl");
16969
16971
  __publicField$C(this, "_currentOverlay");
16972
+ __publicField$C(this, "_loadedOverlay");
16970
16973
  this._url = url;
16971
16974
  const params = {};
16972
16975
  const opts = {};
@@ -17020,15 +17023,18 @@ class ImageLayer extends leafletSrcExports.Layer {
17020
17023
  this._currentUrl = url;
17021
17024
  const viewPortBuffer = this.options.viewPortBuffer || 0;
17022
17025
  const bounds = this._map.getBounds().pad(viewPortBuffer);
17026
+ if (this._loadedOverlay) {
17027
+ this._loadedOverlay.cancelLoad();
17028
+ this._loadedOverlay.off("load");
17029
+ this._loadedOverlay = void 0;
17030
+ }
17023
17031
  const overlay = new ImageOverlay(url, bounds, {
17024
17032
  opacity: 0,
17025
17033
  pane: this.options.pane,
17026
17034
  headers: this.options.headers
17027
17035
  });
17028
17036
  overlay.addTo(this._map);
17029
- if (this._currentOverlay) {
17030
- this._currentOverlay.cancelLoad();
17031
- }
17037
+ this._loadedOverlay = overlay;
17032
17038
  overlay.once(
17033
17039
  "load",
17034
17040
  () => {
@@ -17041,6 +17047,7 @@ class ImageLayer extends leafletSrcExports.Layer {
17041
17047
  } else if (this._currentOverlay) {
17042
17048
  this._map.removeLayer(this._currentOverlay);
17043
17049
  }
17050
+ this._loadedOverlay = void 0;
17044
17051
  this._currentOverlay = overlay;
17045
17052
  overlay.setOpacity(
17046
17053
  this.options.opacity !== void 0 ? this.options.opacity : 1