@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.
package/lib/index.d.ts CHANGED
@@ -45,6 +45,7 @@ declare class LeafletMapAdapter implements MapAdapter<Map_2, any, Control> {
45
45
  };
46
46
  emitter: EventEmitter;
47
47
  map?: Map_2;
48
+ private _resizeObserver?;
48
49
  private _unselectCb;
49
50
  private _universalEvents;
50
51
  create(options: MapOptions): void;
@@ -75,6 +76,8 @@ declare class LeafletMapAdapter implements MapAdapter<Map_2, any, Control> {
75
76
  onMapClick(evt: LeafletMouseEvent): void;
76
77
  locate(opt: LocateOptions, events?: LocationEvents): Locate;
77
78
  private _addUnselectCb;
79
+ private _watchSizeChangeToUpdateMinZoom;
80
+ private _stopWatchSizeChangeToUpdateMinZoom;
78
81
  private _addMapListeners;
79
82
  }
80
83
  export default LeafletMapAdapter;
@@ -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 commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
3
3
 
4
4
  var events = {exports: {}};
@@ -15951,6 +15951,7 @@ class LeafletMapAdapter$1 {
15951
15951
  if (this.map) {
15952
15952
  this.map.remove();
15953
15953
  }
15954
+ this._stopWatchSizeChangeToUpdateMinZoom();
15954
15955
  }
15955
15956
  getContainer() {
15956
15957
  return this.map && this.map.getContainer();
@@ -16001,17 +16002,22 @@ class LeafletMapAdapter$1 {
16001
16002
  }
16002
16003
  if (maxBounds !== undefined) {
16003
16004
  if (maxBounds) {
16004
- map.setMaxBounds(arrayToBoundsExpression(maxBounds));
16005
+ const b = arrayToBoundsExpression(maxBounds);
16006
+ map.setMaxBounds(b);
16007
+ map.setMinZoom(map.getBoundsZoom(b));
16008
+ this._watchSizeChangeToUpdateMinZoom(b);
16005
16009
  }
16006
16010
  else {
16007
16011
  // @ts-ignore `null` works for unset maxBounds, but not in typing
16008
16012
  map.setMaxBounds(null);
16013
+ this._stopWatchSizeChangeToUpdateMinZoom();
16009
16014
  }
16010
16015
  }
16011
16016
  if (maxZoom !== undefined) {
16012
16017
  map.setMaxZoom(maxZoom);
16013
16018
  }
16014
16019
  if (minZoom !== undefined) {
16020
+ this._stopWatchSizeChangeToUpdateMinZoom();
16015
16021
  map.setMinZoom(minZoom);
16016
16022
  }
16017
16023
  }
@@ -16146,6 +16152,27 @@ class LeafletMapAdapter$1 {
16146
16152
  this._unselectCb.length = 0;
16147
16153
  this._unselectCb.push(cb);
16148
16154
  }
16155
+ _watchSizeChangeToUpdateMinZoom(bounds) {
16156
+ this._stopWatchSizeChangeToUpdateMinZoom();
16157
+ const container = this.getContainer();
16158
+ const map = this.map;
16159
+ if (container && map && window.ResizeObserver) {
16160
+ this._resizeObserver = new ResizeObserver(() => {
16161
+ map.setMinZoom(map.getBoundsZoom(bounds));
16162
+ });
16163
+ this._resizeObserver.observe(container);
16164
+ }
16165
+ }
16166
+ _stopWatchSizeChangeToUpdateMinZoom() {
16167
+ const map = this.map;
16168
+ if (map) {
16169
+ map.setMinZoom(0);
16170
+ }
16171
+ if (this._resizeObserver) {
16172
+ this._resizeObserver.disconnect();
16173
+ this._resizeObserver = undefined;
16174
+ }
16175
+ }
16149
16176
  _addMapListeners() {
16150
16177
  const map = this.map;
16151
16178
  if (map) {