@nextgis/leaflet-map-adapter 3.0.0-alpha.3 → 3.0.0-alpha.5

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: 3.0.0-alpha.3; author: NextGIS */
1
+ /** Bundle of @nextgis/leaflet-map-adapter; version: 3.0.0-alpha.5; author: NextGIS */
2
2
  var LeafletMapAdapter = (function () {
3
3
  'use strict';
4
4
 
@@ -32,7 +32,7 @@ var LeafletMapAdapter = (function () {
32
32
  this.domain = null;
33
33
  if (EventEmitter.usingDomains) {
34
34
  // if there is an active domain, then attach to it.
35
- if (domain.active ) ;
35
+ if (domain.active) ;
36
36
  }
37
37
 
38
38
  if (!this._events || this._events === Object.getPrototypeOf(this)._events) {
@@ -14656,6 +14656,21 @@ var LeafletMapAdapter = (function () {
14656
14656
  return wrapper;
14657
14657
  }
14658
14658
 
14659
+ function updateUrlParams(urlStr, params) {
14660
+ const url = new URL(urlStr);
14661
+ const searchParams = new URLSearchParams(url.search);
14662
+ Object.entries(params).forEach(([key, value]) => {
14663
+ if (value === void 0) {
14664
+ searchParams.delete(key);
14665
+ } else {
14666
+ searchParams.set(key, value);
14667
+ }
14668
+ });
14669
+ searchParams.set("timestamp", String((/* @__PURE__ */ new Date()).getTime()));
14670
+ const newSearch = [...searchParams.entries()].map(([key, value]) => `${key}=${value}`).join("&");
14671
+ return `${url.origin}${url.pathname}?${newSearch}`;
14672
+ }
14673
+
14659
14674
  function boundsToArray(bounds) {
14660
14675
  const ne = bounds.getNorthEast();
14661
14676
  const sw = bounds.getSouthWest();
@@ -15821,6 +15836,7 @@ var LeafletMapAdapter = (function () {
15821
15836
  var __publicField$2 = (obj, key, value) => __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
15822
15837
  class ImageLayer extends leafletSrcExports.Layer {
15823
15838
  constructor(url, options) {
15839
+ var _a;
15824
15840
  super(options);
15825
15841
  __publicField$2(this, "defaultWmsParams", {
15826
15842
  service: "WMS",
@@ -15861,7 +15877,11 @@ var LeafletMapAdapter = (function () {
15861
15877
  }
15862
15878
  }
15863
15879
  leafletSrcExports.Util.setOptions(this, opts);
15864
- this.wmsParams = leafletSrcExports.Util.extend({}, this.defaultWmsParams, params);
15880
+ this.wmsParams = leafletSrcExports.Util.extend(
15881
+ {},
15882
+ this.defaultWmsParams,
15883
+ (_a = params == null ? void 0 : params.params) != null ? _a : {}
15884
+ );
15865
15885
  }
15866
15886
  setParams(params) {
15867
15887
  leafletSrcExports.Util.extend(this.wmsParams, params);
@@ -16050,6 +16070,13 @@ var LeafletMapAdapter = (function () {
16050
16070
  return this.layer;
16051
16071
  }
16052
16072
  }
16073
+ updateLayer(options) {
16074
+ if (this.layer) {
16075
+ const params = (options == null ? void 0 : options.params) || {};
16076
+ leafletSrcExports.Util.extend(this.layer.wmsParams, params);
16077
+ this.layer.update();
16078
+ }
16079
+ }
16053
16080
  }
16054
16081
  __publicField$1(ImageAdapter, "queue", imageQueue);
16055
16082
 
@@ -16173,13 +16200,12 @@ var LeafletMapAdapter = (function () {
16173
16200
  }
16174
16201
  }
16175
16202
  }
16176
- updateLayer() {
16203
+ updateLayer(options) {
16177
16204
  if (this.layer) {
16178
16205
  const currentUrl = this.layer._url;
16179
- const timestamp = (/* @__PURE__ */ new Date()).getTime();
16180
- const separator = currentUrl.includes("?") ? "&" : "?";
16181
- const newUrl = currentUrl.replace(/(\?|&)timestamp=\d*/g, "") + separator + `timestamp=${timestamp}`;
16182
- this.layer.setUrl(newUrl);
16206
+ if (options == null ? void 0 : options.params) {
16207
+ this.layer.setUrl(updateUrlParams(currentUrl, options.params));
16208
+ }
16183
16209
  this.layer.redraw();
16184
16210
  }
16185
16211
  }