@nextgis/ngw-leaflet 2.0.0 → 2.1.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/README.md CHANGED
@@ -48,9 +48,7 @@ We recommend linking to a specific version number `/ngw-leaflet@[version]`
48
48
  ### In Node.js
49
49
 
50
50
  ```bash
51
- $ npm install --save-dev @nextgis/ngw-leaflet
52
- # or
53
- $ yarn add @nextgis/ngw-leaflet
51
+ npm install leaflet @nextgis/ngw-leaflet
54
52
  ```
55
53
 
56
54
  ## Usage
@@ -66,7 +64,7 @@ const ngwMap = new NgwMap({
66
64
  });
67
65
  ```
68
66
 
69
- Check out the [API Documentation](https://code-api.nextgis.com/modules/ngw_map.html)
67
+ Check out the [API Documentation](https://code-api.nextgis.com/modules/_nextgis_ngw_map.html)
70
68
 
71
69
  ## Commercial support
72
70
 
@@ -1,4 +1,4 @@
1
- /** Bundle of @nextgis/ngw-leaflet; version: 2.0.0; author: NextGIS */
1
+ /** Bundle of @nextgis/ngw-leaflet; version: 2.1.0; author: NextGIS */
2
2
  function styleInject(css, ref) {
3
3
  if ( ref === void 0 ) ref = {};
4
4
  var insertAt = ref.insertAt;
@@ -17286,6 +17286,16 @@ class TileAdapter extends BaseAdapter {
17286
17286
  }
17287
17287
  }
17288
17288
  }
17289
+ updateLayer() {
17290
+ if (this.layer) {
17291
+ const currentUrl = this.layer._url;
17292
+ const timestamp = (/* @__PURE__ */ new Date()).getTime();
17293
+ const separator = currentUrl.includes("?") ? "&" : "?";
17294
+ const newUrl = currentUrl.replace(/(\?|&)timestamp=\d*/g, "") + separator + `timestamp=${timestamp}`;
17295
+ this.layer.setUrl(newUrl);
17296
+ this.layer.redraw();
17297
+ }
17298
+ }
17289
17299
  }
17290
17300
 
17291
17301
  var __defProp$N = Object.defineProperty;
@@ -17453,6 +17463,8 @@ const _LeafletMapAdapter = class _LeafletMapAdapter {
17453
17463
  center: center && [center[1], center[0]],
17454
17464
  zoom
17455
17465
  }, mapAdapterOptions));
17466
+ this._updateMinZoomForBounds(minZoom);
17467
+ this._watchSizeChangeToUpdateMinZoom();
17456
17468
  const defPane = this.map.createPane("order-0");
17457
17469
  this.map._addUnselectCb = (def) => {
17458
17470
  this._addUnselectCb(def);
@@ -17516,19 +17528,17 @@ const _LeafletMapAdapter = class _LeafletMapAdapter {
17516
17528
  if (maxBounds) {
17517
17529
  const b = arrayToBoundsExpression(maxBounds);
17518
17530
  map.setMaxBounds(b);
17519
- map.setMinZoom(map.getBoundsZoom(b));
17520
- this._watchSizeChangeToUpdateMinZoom(b);
17531
+ this._updateMinZoomForBounds();
17521
17532
  } else {
17522
17533
  map.setMaxBounds(null);
17523
- this._stopWatchSizeChangeToUpdateMinZoom();
17534
+ this._updateMinZoomForBounds();
17524
17535
  }
17525
17536
  }
17526
17537
  if (maxZoom !== void 0) {
17527
17538
  map.setMaxZoom(maxZoom);
17528
17539
  }
17529
17540
  if (minZoom !== void 0) {
17530
- this._stopWatchSizeChangeToUpdateMinZoom();
17531
- map.setMinZoom(minZoom);
17541
+ this._updateMinZoomForBounds(minZoom);
17532
17542
  }
17533
17543
  }
17534
17544
  }
@@ -17662,22 +17672,18 @@ const _LeafletMapAdapter = class _LeafletMapAdapter {
17662
17672
  this._unselectCb.length = 0;
17663
17673
  this._unselectCb.push(cb);
17664
17674
  }
17665
- _watchSizeChangeToUpdateMinZoom(bounds) {
17675
+ _watchSizeChangeToUpdateMinZoom() {
17666
17676
  this._stopWatchSizeChangeToUpdateMinZoom();
17667
17677
  const container = this.getContainer();
17668
17678
  const map = this.map;
17669
17679
  if (container && map && window.ResizeObserver) {
17670
17680
  this._resizeObserver = new ResizeObserver(() => {
17671
- map.setMinZoom(map.getBoundsZoom(bounds));
17681
+ this._updateMinZoomForBounds();
17672
17682
  });
17673
17683
  this._resizeObserver.observe(container);
17674
17684
  }
17675
17685
  }
17676
17686
  _stopWatchSizeChangeToUpdateMinZoom() {
17677
- const map = this.map;
17678
- if (map) {
17679
- map.setMinZoom(0);
17680
- }
17681
17687
  if (this._resizeObserver) {
17682
17688
  this._resizeObserver.disconnect();
17683
17689
  this._resizeObserver = void 0;
@@ -17704,6 +17710,28 @@ const _LeafletMapAdapter = class _LeafletMapAdapter {
17704
17710
  }
17705
17711
  }
17706
17712
  }
17713
+ _updateMinZoomForBounds(zoom) {
17714
+ var _a;
17715
+ const map = this.map;
17716
+ if (map) {
17717
+ zoom = zoom != null ? zoom : map.getMinZoom();
17718
+ const defaultBounds = leafletSrcExports.latLngBounds(
17719
+ leafletSrcExports.latLng(-90, -18e3),
17720
+ leafletSrcExports.latLng(90, 18e3)
17721
+ );
17722
+ const maxBounds = (_a = map.options.maxBounds) != null ? _a : defaultBounds;
17723
+ if (maxBounds !== void 0) {
17724
+ map.setMinZoom(0);
17725
+ const boundsZoom = map.getBoundsZoom(maxBounds, true);
17726
+ const minZoom = zoom < boundsZoom ? boundsZoom : zoom;
17727
+ map.options.minZoom = minZoom;
17728
+ map.setMinZoom(minZoom);
17729
+ if (map.getZoom() < minZoom) {
17730
+ map.setZoom(minZoom);
17731
+ }
17732
+ }
17733
+ }
17734
+ }
17707
17735
  };
17708
17736
  __publicField$A(_LeafletMapAdapter, "layerAdapters", {
17709
17737
  GEOJSON: GeoJsonAdapter,
@@ -23610,6 +23638,9 @@ const _WebMapMain = class _WebMapMain {
23610
23638
  this.setView(center, zoom);
23611
23639
  } else if (bounds) {
23612
23640
  this.fitBounds(bounds);
23641
+ if (zoom !== void 0) {
23642
+ this.setZoom(zoom);
23643
+ }
23613
23644
  }
23614
23645
  }
23615
23646
  _setInitMapState(states) {