@nextgis/leaflet-map-adapter 1.10.0 → 1.11.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: 1.10.0; author: NextGIS */
1
+ /** Bundle of @nextgis/leaflet-map-adapter; version: 1.11.0; author: NextGIS */
2
2
  var LeafletMapAdapter = (function () {
3
3
  'use strict';
4
4
 
@@ -94,10 +94,14 @@ var LeafletMapAdapter = (function () {
94
94
  }
95
95
  }
96
96
 
97
- function __spreadArray(to, from) {
98
- for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
99
- to[j] = from[i];
100
- return to;
97
+ function __spreadArray(to, from, pack) {
98
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
99
+ if (ar || !(i in from)) {
100
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
101
+ ar[i] = from[i];
102
+ }
103
+ }
104
+ return to.concat(ar || Array.prototype.slice.call(from));
101
105
  }
102
106
 
103
107
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
@@ -15870,7 +15874,7 @@ var LeafletMapAdapter = (function () {
15870
15874
  a[_i] = arguments[_i];
15871
15875
  }
15872
15876
  // @ts-ignore
15873
- (_a = leafletSrc.exports.GridLayer.prototype._update).call.apply(_a, __spreadArray([_this], a));
15877
+ (_a = leafletSrc.exports.GridLayer.prototype._update).call.apply(_a, __spreadArray([_this], a, false));
15874
15878
  }, _this.options.setViewDelay);
15875
15879
  }
15876
15880
  return _this;
@@ -16047,6 +16051,7 @@ var LeafletMapAdapter = (function () {
16047
16051
  if (this.map) {
16048
16052
  this.map.remove();
16049
16053
  }
16054
+ this._stopWatchSizeChangeToUpdateMinZoom();
16050
16055
  };
16051
16056
  LeafletMapAdapter.prototype.getContainer = function () {
16052
16057
  return this.map && this.map.getContainer();
@@ -16097,17 +16102,22 @@ var LeafletMapAdapter = (function () {
16097
16102
  }
16098
16103
  if (maxBounds !== undefined) {
16099
16104
  if (maxBounds) {
16100
- map.setMaxBounds(arrayToBoundsExpression(maxBounds));
16105
+ var b = arrayToBoundsExpression(maxBounds);
16106
+ map.setMaxBounds(b);
16107
+ map.setMinZoom(map.getBoundsZoom(b));
16108
+ this._watchSizeChangeToUpdateMinZoom(b);
16101
16109
  }
16102
16110
  else {
16103
16111
  // @ts-ignore `null` works for unset maxBounds, but not in typing
16104
16112
  map.setMaxBounds(null);
16113
+ this._stopWatchSizeChangeToUpdateMinZoom();
16105
16114
  }
16106
16115
  }
16107
16116
  if (maxZoom !== undefined) {
16108
16117
  map.setMaxZoom(maxZoom);
16109
16118
  }
16110
16119
  if (minZoom !== undefined) {
16120
+ this._stopWatchSizeChangeToUpdateMinZoom();
16111
16121
  map.setMinZoom(minZoom);
16112
16122
  }
16113
16123
  }
@@ -16244,6 +16254,27 @@ var LeafletMapAdapter = (function () {
16244
16254
  this._unselectCb.length = 0;
16245
16255
  this._unselectCb.push(cb);
16246
16256
  };
16257
+ LeafletMapAdapter.prototype._watchSizeChangeToUpdateMinZoom = function (bounds) {
16258
+ this._stopWatchSizeChangeToUpdateMinZoom();
16259
+ var container = this.getContainer();
16260
+ var map = this.map;
16261
+ if (container && map && window.ResizeObserver) {
16262
+ this._resizeObserver = new ResizeObserver(function () {
16263
+ map.setMinZoom(map.getBoundsZoom(bounds));
16264
+ });
16265
+ this._resizeObserver.observe(container);
16266
+ }
16267
+ };
16268
+ LeafletMapAdapter.prototype._stopWatchSizeChangeToUpdateMinZoom = function () {
16269
+ var map = this.map;
16270
+ if (map) {
16271
+ map.setMinZoom(0);
16272
+ }
16273
+ if (this._resizeObserver) {
16274
+ this._resizeObserver.disconnect();
16275
+ this._resizeObserver = undefined;
16276
+ }
16277
+ };
16247
16278
  LeafletMapAdapter.prototype._addMapListeners = function () {
16248
16279
  var _this = this;
16249
16280
  var map = this.map;