@nextgis/leaflet-map-adapter 3.0.0-alpha.1 → 3.0.0-alpha.4

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
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { EventEmitter } from 'events';
3
2
  import { Control, ControlOptions, Map, Layer, GridLayer, LeafletMouseEvent } from 'leaflet';
4
3
  import { AttributionControlOptions, MapAdapter, LayerAdapter, MapOptions, ViewOptions, FitOptions, MapControl, CreateControlOptions, ButtonControlOptions, LocateOptions, LocationEvents, Locate } from '@nextgis/webmap';
@@ -1,4 +1,4 @@
1
- /** Bundle of @nextgis/leaflet-map-adapter; version: 3.0.0-alpha.1; author: NextGIS */
1
+ /** Bundle of @nextgis/leaflet-map-adapter; version: 3.0.0-alpha.4; author: NextGIS */
2
2
  var domain;
3
3
 
4
4
  // This constructor is used to store event handlers. Instantiating this is
@@ -14653,6 +14653,21 @@ function debounce(cb, wait = 10) {
14653
14653
  return wrapper;
14654
14654
  }
14655
14655
 
14656
+ function updateUrlParams(urlStr, params) {
14657
+ const url = new URL(urlStr);
14658
+ const searchParams = new URLSearchParams(url.search);
14659
+ Object.entries(params).forEach(([key, value]) => {
14660
+ if (value === void 0) {
14661
+ searchParams.delete(key);
14662
+ } else {
14663
+ searchParams.set(key, value);
14664
+ }
14665
+ });
14666
+ searchParams.set("timestamp", String((/* @__PURE__ */ new Date()).getTime()));
14667
+ const newSearch = [...searchParams.entries()].map(([key, value]) => `${key}=${value}`).join("&");
14668
+ return `${url.origin}${url.pathname}?${newSearch}`;
14669
+ }
14670
+
14656
14671
  function boundsToArray(bounds) {
14657
14672
  const ne = bounds.getNorthEast();
14658
14673
  const sw = bounds.getSouthWest();
@@ -15818,6 +15833,7 @@ var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key,
15818
15833
  var __publicField$2 = (obj, key, value) => __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
15819
15834
  class ImageLayer extends leafletSrcExports.Layer {
15820
15835
  constructor(url, options) {
15836
+ var _a;
15821
15837
  super(options);
15822
15838
  __publicField$2(this, "defaultWmsParams", {
15823
15839
  service: "WMS",
@@ -15858,7 +15874,11 @@ class ImageLayer extends leafletSrcExports.Layer {
15858
15874
  }
15859
15875
  }
15860
15876
  leafletSrcExports.Util.setOptions(this, opts);
15861
- this.wmsParams = leafletSrcExports.Util.extend({}, this.defaultWmsParams, params);
15877
+ this.wmsParams = leafletSrcExports.Util.extend(
15878
+ {},
15879
+ this.defaultWmsParams,
15880
+ (_a = params == null ? void 0 : params.params) != null ? _a : {}
15881
+ );
15862
15882
  }
15863
15883
  setParams(params) {
15864
15884
  leafletSrcExports.Util.extend(this.wmsParams, params);
@@ -16047,6 +16067,13 @@ class ImageAdapter extends BaseAdapter {
16047
16067
  return this.layer;
16048
16068
  }
16049
16069
  }
16070
+ updateLayer(options) {
16071
+ if (this.layer) {
16072
+ const params = (options == null ? void 0 : options.params) || {};
16073
+ leafletSrcExports.Util.extend(this.layer.wmsParams, params);
16074
+ this.layer.update();
16075
+ }
16076
+ }
16050
16077
  }
16051
16078
  __publicField$1(ImageAdapter, "queue", imageQueue);
16052
16079
 
@@ -16170,13 +16197,12 @@ class TileAdapter extends BaseAdapter {
16170
16197
  }
16171
16198
  }
16172
16199
  }
16173
- updateLayer() {
16200
+ updateLayer(options) {
16174
16201
  if (this.layer) {
16175
16202
  const currentUrl = this.layer._url;
16176
- const timestamp = (/* @__PURE__ */ new Date()).getTime();
16177
- const separator = currentUrl.includes("?") ? "&" : "?";
16178
- const newUrl = currentUrl.replace(/(\?|&)timestamp=\d*/g, "") + separator + `timestamp=${timestamp}`;
16179
- this.layer.setUrl(newUrl);
16203
+ if (options == null ? void 0 : options.params) {
16204
+ this.layer.setUrl(updateUrlParams(currentUrl, options.params));
16205
+ }
16180
16206
  this.layer.redraw();
16181
16207
  }
16182
16208
  }