@nextgis/leaflet-map-adapter 1.9.2 → 1.11.7

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.9.2; author: NextGIS */
1
+ /** Bundle of @nextgis/leaflet-map-adapter; version: 1.11.7; 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 : {};
@@ -14664,6 +14668,9 @@ var LeafletMapAdapter = (function () {
14664
14668
  if (options.bar) {
14665
14669
  element.classList.add('leaflet-bar');
14666
14670
  }
14671
+ if (options.addClass) {
14672
+ element.classList.add(options.addClass);
14673
+ }
14667
14674
  if (!options.margin && !options.bar) {
14668
14675
  element.style.marginBottom = '0px';
14669
14676
  element.style.marginTop = '0px';
@@ -15424,13 +15431,13 @@ var LeafletMapAdapter = (function () {
15424
15431
  };
15425
15432
  GeoJsonAdapter.prototype._handleMouseEvents = function (layer) {
15426
15433
  var _this = this;
15427
- var isSelected = function (l) { return _this._selectedLayers.indexOf(l) !== -1; };
15428
15434
  var _a = this.options, onClick = _a.onClick, onLayerClick = _a.onLayerClick, onMouseOut = _a.onMouseOut, onMouseOver = _a.onMouseOver;
15429
15435
  // TODO: remove backward compatibility for onLayerClick
15430
15436
  var onClick_ = onClick || onLayerClick;
15431
15437
  if (onClick_) {
15432
15438
  layer.on('click', function (e) {
15433
- onClick_(__assign({ selected: isSelected(e.target) }, _this._createMouseEvent(e)));
15439
+ var selected = !!_this._getSelected(layer);
15440
+ onClick_(__assign({ selected: selected }, _this._createMouseEvent(e)));
15434
15441
  }, this);
15435
15442
  }
15436
15443
  if (onMouseOut) {
@@ -15450,12 +15457,15 @@ var LeafletMapAdapter = (function () {
15450
15457
  source: source,
15451
15458
  });
15452
15459
  };
15460
+ GeoJsonAdapter.prototype._getSelected = function (layer) {
15461
+ return this._selectedLayers.find(function (x) { return x.layer === layer; });
15462
+ };
15453
15463
  GeoJsonAdapter.prototype._selectOnLayerClick = function (e) {
15454
15464
  leafletSrc.exports.DomEvent.stopPropagation(e);
15455
15465
  var layer = e.target;
15456
15466
  var feature = layer.feature;
15457
15467
  var def = __assign({ target: this, layer: layer, feature: feature }, createFeaturePositionOptions(feature));
15458
- var isSelected = this._selectedLayers.find(function (x) { return x.layer === layer; });
15468
+ var isSelected = this._getSelected(layer);
15459
15469
  if (isSelected) {
15460
15470
  if (this.options && this.options.unselectOnSecondClick) {
15461
15471
  this._unSelectLayer(isSelected);
@@ -15864,7 +15874,7 @@ var LeafletMapAdapter = (function () {
15864
15874
  a[_i] = arguments[_i];
15865
15875
  }
15866
15876
  // @ts-ignore
15867
- (_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));
15868
15878
  }, _this.options.setViewDelay);
15869
15879
  }
15870
15880
  return _this;
@@ -16041,6 +16051,7 @@ var LeafletMapAdapter = (function () {
16041
16051
  if (this.map) {
16042
16052
  this.map.remove();
16043
16053
  }
16054
+ this._stopWatchSizeChangeToUpdateMinZoom();
16044
16055
  };
16045
16056
  LeafletMapAdapter.prototype.getContainer = function () {
16046
16057
  return this.map && this.map.getContainer();
@@ -16091,17 +16102,22 @@ var LeafletMapAdapter = (function () {
16091
16102
  }
16092
16103
  if (maxBounds !== undefined) {
16093
16104
  if (maxBounds) {
16094
- map.setMaxBounds(arrayToBoundsExpression(maxBounds));
16105
+ var b = arrayToBoundsExpression(maxBounds);
16106
+ map.setMaxBounds(b);
16107
+ map.setMinZoom(map.getBoundsZoom(b));
16108
+ this._watchSizeChangeToUpdateMinZoom(b);
16095
16109
  }
16096
16110
  else {
16097
16111
  // @ts-ignore `null` works for unset maxBounds, but not in typing
16098
16112
  map.setMaxBounds(null);
16113
+ this._stopWatchSizeChangeToUpdateMinZoom();
16099
16114
  }
16100
16115
  }
16101
16116
  if (maxZoom !== undefined) {
16102
16117
  map.setMaxZoom(maxZoom);
16103
16118
  }
16104
16119
  if (minZoom !== undefined) {
16120
+ this._stopWatchSizeChangeToUpdateMinZoom();
16105
16121
  map.setMinZoom(minZoom);
16106
16122
  }
16107
16123
  }
@@ -16238,6 +16254,27 @@ var LeafletMapAdapter = (function () {
16238
16254
  this._unselectCb.length = 0;
16239
16255
  this._unselectCb.push(cb);
16240
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
+ };
16241
16278
  LeafletMapAdapter.prototype._addMapListeners = function () {
16242
16279
  var _this = this;
16243
16280
  var map = this.map;