@nextgis/leaflet-map-adapter 1.9.4 → 1.11.10

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/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ![size](https://img.shields.io/bundlephobia/minzip/@nextgis/leaflet-map-adapter) ![version](https://img.shields.io/npm/v/@nextgis/leaflet-map-adapter)
4
4
 
5
- WebMap adapter to use [Laeflet](https://leafletjs.com/) GIS framework.
5
+ WebMap adapter to use [Leaflet](https://leafletjs.com/) GIS framework.
6
6
 
7
7
  ## Install
8
8
 
@@ -31,6 +31,6 @@ webMap.create(options).then(() => {
31
31
 
32
32
  ## Commercial support
33
33
 
34
- Need to fix a bug or add a feature to @nextgis/leaflet-map-adapter? We provide custom development and support for this software. [Contact us](http://nextgis.com/contact/) to discuss options!
34
+ Need to fix a bug or add a feature to `@nextgis/leaflet-map-adapter`? We provide custom development and support for this software. [Contact us](http://nextgis.com/contact/) to discuss options!
35
35
 
36
36
  [![http://nextgis.com](https://nextgis.ru/img/nextgis.png)](http://nextgis.com)
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.9.4; author: NextGIS */
1
+ /** Bundle of @nextgis/leaflet-map-adapter; version: 1.11.10; 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: {}};
@@ -14562,6 +14562,9 @@ function createControl(control, options = {}, map) {
14562
14562
  if (options.bar) {
14563
14563
  element.classList.add('leaflet-bar');
14564
14564
  }
14565
+ if (options.addClass) {
14566
+ element.classList.add(options.addClass);
14567
+ }
14565
14568
  if (!options.margin && !options.bar) {
14566
14569
  element.style.marginBottom = '0px';
14567
14570
  element.style.marginTop = '0px';
@@ -15090,7 +15093,7 @@ class GeoJsonAdapter extends BaseAdapter {
15090
15093
  async _openPopup(def, options = {}, type, latLng) {
15091
15094
  var _a, _b;
15092
15095
  const { feature, layer } = def;
15093
- const { minWidth, autoPan, maxWidth, closeButton: closeButton_ } = {
15096
+ const { minWidth, autoPan, maxWidth, closeButton: closeButton_, } = {
15094
15097
  minWidth: 300,
15095
15098
  ...options,
15096
15099
  };
@@ -15286,7 +15289,7 @@ class GeoJsonAdapter extends BaseAdapter {
15286
15289
  ok = this._filterFun(def);
15287
15290
  }
15288
15291
  if (ok) {
15289
- const { popup, popupOptions, selectable, interactive, selectOnHover, } = this.options;
15292
+ const { popup, popupOptions, selectable, interactive, selectOnHover } = this.options;
15290
15293
  // @ts-ignore
15291
15294
  layer.options.interactive = defined(interactive) ? interactive : true;
15292
15295
  layer_.addLayer(layer);
@@ -15948,6 +15951,7 @@ class LeafletMapAdapter$1 {
15948
15951
  if (this.map) {
15949
15952
  this.map.remove();
15950
15953
  }
15954
+ this._stopWatchSizeChangeToUpdateMinZoom();
15951
15955
  }
15952
15956
  getContainer() {
15953
15957
  return this.map && this.map.getContainer();
@@ -15998,17 +16002,22 @@ class LeafletMapAdapter$1 {
15998
16002
  }
15999
16003
  if (maxBounds !== undefined) {
16000
16004
  if (maxBounds) {
16001
- map.setMaxBounds(arrayToBoundsExpression(maxBounds));
16005
+ const b = arrayToBoundsExpression(maxBounds);
16006
+ map.setMaxBounds(b);
16007
+ map.setMinZoom(map.getBoundsZoom(b));
16008
+ this._watchSizeChangeToUpdateMinZoom(b);
16002
16009
  }
16003
16010
  else {
16004
16011
  // @ts-ignore `null` works for unset maxBounds, but not in typing
16005
16012
  map.setMaxBounds(null);
16013
+ this._stopWatchSizeChangeToUpdateMinZoom();
16006
16014
  }
16007
16015
  }
16008
16016
  if (maxZoom !== undefined) {
16009
16017
  map.setMaxZoom(maxZoom);
16010
16018
  }
16011
16019
  if (minZoom !== undefined) {
16020
+ this._stopWatchSizeChangeToUpdateMinZoom();
16012
16021
  map.setMinZoom(minZoom);
16013
16022
  }
16014
16023
  }
@@ -16143,6 +16152,27 @@ class LeafletMapAdapter$1 {
16143
16152
  this._unselectCb.length = 0;
16144
16153
  this._unselectCb.push(cb);
16145
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
+ }
16146
16176
  _addMapListeners() {
16147
16177
  const map = this.map;
16148
16178
  if (map) {