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

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.1; 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();
@@ -14921,8 +14936,8 @@ var LeafletMapAdapter = (function () {
14921
14936
  }
14922
14937
 
14923
14938
  var __defProp$9 = Object.defineProperty;
14924
- var __defProps$4 = Object.defineProperties;
14925
- var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
14939
+ var __defProps$5 = Object.defineProperties;
14940
+ var __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors;
14926
14941
  var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
14927
14942
  var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
14928
14943
  var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
@@ -14938,7 +14953,7 @@ var LeafletMapAdapter = (function () {
14938
14953
  }
14939
14954
  return a;
14940
14955
  };
14941
- var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
14956
+ var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
14942
14957
  var __objRest$2 = (source, exclude) => {
14943
14958
  var target = {};
14944
14959
  for (var prop in source)
@@ -15033,7 +15048,7 @@ var LeafletMapAdapter = (function () {
15033
15048
  if (html) {
15034
15049
  element.innerHTML = html;
15035
15050
  }
15036
- const divIcon = new leafletSrcExports.DivIcon(__spreadProps$4(__spreadValues$6({
15051
+ const divIcon = new leafletSrcExports.DivIcon(__spreadProps$5(__spreadValues$6({
15037
15052
  className: ""
15038
15053
  }, toLIconOpt), {
15039
15054
  html: element
@@ -15082,8 +15097,8 @@ var LeafletMapAdapter = (function () {
15082
15097
  }
15083
15098
 
15084
15099
  var __defProp$8 = Object.defineProperty;
15085
- var __defProps$3 = Object.defineProperties;
15086
- var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
15100
+ var __defProps$4 = Object.defineProperties;
15101
+ var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
15087
15102
  var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
15088
15103
  var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
15089
15104
  var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
@@ -15099,7 +15114,7 @@ var LeafletMapAdapter = (function () {
15099
15114
  }
15100
15115
  return a;
15101
15116
  };
15102
- var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
15117
+ var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
15103
15118
  var __publicField$5 = (obj, key, value) => __defNormalProp$8(obj, typeof key !== "symbol" ? key + "" : key, value);
15104
15119
  var __async = (__this, __arguments, generator) => {
15105
15120
  return new Promise((resolve, reject) => {
@@ -15148,7 +15163,7 @@ var LeafletMapAdapter = (function () {
15148
15163
  addLayer(options) {
15149
15164
  Object.assign(this.options, options);
15150
15165
  this.paint = options.paint;
15151
- this.layer = new leafletSrcExports.FeatureGroup([], __spreadProps$3(__spreadValues$5({}, options.nativeOptions), {
15166
+ this.layer = new leafletSrcExports.FeatureGroup([], __spreadProps$4(__spreadValues$5({}, options.nativeOptions), {
15152
15167
  pane: this.pane
15153
15168
  }));
15154
15169
  this.selectedPaint = options.selectedPaint;
@@ -15498,7 +15513,7 @@ var LeafletMapAdapter = (function () {
15498
15513
  if (feature) {
15499
15514
  return this._paint.preparePaint(__spreadValues$5(__spreadValues$5({}, PAINT), paint(feature)));
15500
15515
  } else {
15501
- return this._paint.preparePaint(__spreadProps$3(__spreadValues$5({}, PAINT), { type: "path" }));
15516
+ return this._paint.preparePaint(__spreadProps$4(__spreadValues$5({}, PAINT), { type: "path" }));
15502
15517
  }
15503
15518
  }
15504
15519
  };
@@ -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",
@@ -15838,6 +15854,7 @@ var LeafletMapAdapter = (function () {
15838
15854
  opacity: 1,
15839
15855
  isBack: false,
15840
15856
  minZoom: 0,
15857
+ maxZoom: void 0,
15841
15858
  pane: "tilePane",
15842
15859
  headers: null,
15843
15860
  withCredentials: false,
@@ -15861,7 +15878,11 @@ var LeafletMapAdapter = (function () {
15861
15878
  }
15862
15879
  }
15863
15880
  leafletSrcExports.Util.setOptions(this, opts);
15864
- this.wmsParams = leafletSrcExports.Util.extend({}, this.defaultWmsParams, params);
15881
+ this.wmsParams = leafletSrcExports.Util.extend(
15882
+ {},
15883
+ this.defaultWmsParams,
15884
+ (_a = params == null ? void 0 : params.params) != null ? _a : {}
15885
+ );
15865
15886
  }
15866
15887
  setParams(params) {
15867
15888
  leafletSrcExports.Util.extend(this.wmsParams, params);
@@ -16009,6 +16030,8 @@ var LeafletMapAdapter = (function () {
16009
16030
  }
16010
16031
 
16011
16032
  var __defProp$4 = Object.defineProperty;
16033
+ var __defProps$3 = Object.defineProperties;
16034
+ var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
16012
16035
  var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
16013
16036
  var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
16014
16037
  var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
@@ -16024,6 +16047,7 @@ var LeafletMapAdapter = (function () {
16024
16047
  }
16025
16048
  return a;
16026
16049
  };
16050
+ var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
16027
16051
  var __publicField$1 = (obj, key, value) => __defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
16028
16052
  class ImageAdapter extends BaseAdapter {
16029
16053
  constructor() {
@@ -16031,15 +16055,21 @@ var LeafletMapAdapter = (function () {
16031
16055
  __publicField$1(this, "layer");
16032
16056
  }
16033
16057
  addLayer(options) {
16058
+ var _a;
16034
16059
  const url = options && options.url;
16035
16060
  if (url) {
16036
- options = __spreadValues$4({ transparent: true }, options);
16037
16061
  const updateWmsParamsFromOpt = options.updateWmsParams;
16038
- this.layer = new ImageLayer(url, __spreadValues$4(__spreadValues$4(__spreadValues$4({
16062
+ this.layer = new ImageLayer(url, __spreadProps$3(__spreadValues$4(__spreadValues$4(__spreadValues$4({
16039
16063
  pane: this.pane,
16040
16064
  headers: options.headers,
16041
16065
  setViewDelay: options.setViewDelay
16042
- }, options), options.params), options.nativeOptions));
16066
+ }, __spreadProps$3(__spreadValues$4({
16067
+ transparent: true
16068
+ }, options), {
16069
+ opacity: (_a = options.opacity) != null ? _a : void 0
16070
+ })), options.params), options.nativeOptions), {
16071
+ maxZoom: 12
16072
+ }));
16043
16073
  if (updateWmsParamsFromOpt) {
16044
16074
  const updateWmsParams = this.layer.updateWmsParams;
16045
16075
  this.layer.updateWmsParams = function(map) {
@@ -16050,6 +16080,13 @@ var LeafletMapAdapter = (function () {
16050
16080
  return this.layer;
16051
16081
  }
16052
16082
  }
16083
+ updateLayer(options) {
16084
+ if (this.layer) {
16085
+ const params = (options == null ? void 0 : options.params) || {};
16086
+ leafletSrcExports.Util.extend(this.layer.wmsParams, params);
16087
+ this.layer.update();
16088
+ }
16089
+ }
16053
16090
  }
16054
16091
  __publicField$1(ImageAdapter, "queue", imageQueue);
16055
16092
 
@@ -16173,13 +16210,12 @@ var LeafletMapAdapter = (function () {
16173
16210
  }
16174
16211
  }
16175
16212
  }
16176
- updateLayer() {
16213
+ updateLayer(options) {
16177
16214
  if (this.layer) {
16178
16215
  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);
16216
+ if (options == null ? void 0 : options.params) {
16217
+ this.layer.setUrl(updateUrlParams(currentUrl, options.params));
16218
+ }
16183
16219
  this.layer.redraw();
16184
16220
  }
16185
16221
  }