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

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.13; 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) {
@@ -14634,10 +14634,6 @@ var LeafletMapAdapter = (function () {
14634
14634
  );
14635
14635
  }
14636
14636
 
14637
- function defined(val) {
14638
- return val !== void 0 && val !== null;
14639
- }
14640
-
14641
14637
  function debounce(cb, wait = 10) {
14642
14638
  let timeoutId;
14643
14639
  function wrapper(...args) {
@@ -14656,6 +14652,25 @@ var LeafletMapAdapter = (function () {
14656
14652
  return wrapper;
14657
14653
  }
14658
14654
 
14655
+ function defined(val) {
14656
+ return val !== void 0 && val !== null;
14657
+ }
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;
@@ -15447,13 +15462,15 @@ var LeafletMapAdapter = (function () {
15447
15462
  const unselectOnClose = (_b = (_a = this.options.popupOptions) == null ? void 0 : _a.unselectOnClose) != null ? _b : true;
15448
15463
  if (unselectOnClose) {
15449
15464
  const p = layer.getPopup();
15450
- p && p.once(
15451
- "remove",
15452
- () => {
15453
- close();
15454
- },
15455
- this
15456
- );
15465
+ if (p) {
15466
+ p.once(
15467
+ "remove",
15468
+ () => {
15469
+ close();
15470
+ },
15471
+ this
15472
+ );
15473
+ }
15457
15474
  }
15458
15475
  this._openedPopup.push([popup, _closeHandlers, def]);
15459
15476
  popup.openPopup(latLng);
@@ -15498,7 +15515,7 @@ var LeafletMapAdapter = (function () {
15498
15515
  if (feature) {
15499
15516
  return this._paint.preparePaint(__spreadValues$5(__spreadValues$5({}, PAINT), paint(feature)));
15500
15517
  } else {
15501
- return this._paint.preparePaint(__spreadProps$3(__spreadValues$5({}, PAINT), { type: "path" }));
15518
+ return this._paint.preparePaint(__spreadProps$4(__spreadValues$5({}, PAINT), { type: "path" }));
15502
15519
  }
15503
15520
  }
15504
15521
  };
@@ -15821,6 +15838,7 @@ var LeafletMapAdapter = (function () {
15821
15838
  var __publicField$2 = (obj, key, value) => __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
15822
15839
  class ImageLayer extends leafletSrcExports.Layer {
15823
15840
  constructor(url, options) {
15841
+ var _a;
15824
15842
  super(options);
15825
15843
  __publicField$2(this, "defaultWmsParams", {
15826
15844
  service: "WMS",
@@ -15838,6 +15856,7 @@ var LeafletMapAdapter = (function () {
15838
15856
  opacity: 1,
15839
15857
  isBack: false,
15840
15858
  minZoom: 0,
15859
+ maxZoom: void 0,
15841
15860
  pane: "tilePane",
15842
15861
  headers: null,
15843
15862
  withCredentials: false,
@@ -15861,7 +15880,11 @@ var LeafletMapAdapter = (function () {
15861
15880
  }
15862
15881
  }
15863
15882
  leafletSrcExports.Util.setOptions(this, opts);
15864
- this.wmsParams = leafletSrcExports.Util.extend({}, this.defaultWmsParams, params);
15883
+ this.wmsParams = leafletSrcExports.Util.extend(
15884
+ {},
15885
+ this.defaultWmsParams,
15886
+ (_a = params == null ? void 0 : params.params) != null ? _a : {}
15887
+ );
15865
15888
  }
15866
15889
  setParams(params) {
15867
15890
  leafletSrcExports.Util.extend(this.wmsParams, params);
@@ -16009,6 +16032,8 @@ var LeafletMapAdapter = (function () {
16009
16032
  }
16010
16033
 
16011
16034
  var __defProp$4 = Object.defineProperty;
16035
+ var __defProps$3 = Object.defineProperties;
16036
+ var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
16012
16037
  var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
16013
16038
  var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
16014
16039
  var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
@@ -16024,6 +16049,7 @@ var LeafletMapAdapter = (function () {
16024
16049
  }
16025
16050
  return a;
16026
16051
  };
16052
+ var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
16027
16053
  var __publicField$1 = (obj, key, value) => __defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
16028
16054
  class ImageAdapter extends BaseAdapter {
16029
16055
  constructor() {
@@ -16031,15 +16057,21 @@ var LeafletMapAdapter = (function () {
16031
16057
  __publicField$1(this, "layer");
16032
16058
  }
16033
16059
  addLayer(options) {
16060
+ var _a;
16034
16061
  const url = options && options.url;
16035
16062
  if (url) {
16036
- options = __spreadValues$4({ transparent: true }, options);
16037
16063
  const updateWmsParamsFromOpt = options.updateWmsParams;
16038
- this.layer = new ImageLayer(url, __spreadValues$4(__spreadValues$4(__spreadValues$4({
16064
+ this.layer = new ImageLayer(url, __spreadProps$3(__spreadValues$4(__spreadValues$4(__spreadValues$4({
16039
16065
  pane: this.pane,
16040
16066
  headers: options.headers,
16041
16067
  setViewDelay: options.setViewDelay
16042
- }, options), options.params), options.nativeOptions));
16068
+ }, __spreadProps$3(__spreadValues$4({
16069
+ transparent: true
16070
+ }, options), {
16071
+ opacity: (_a = options.opacity) != null ? _a : void 0
16072
+ })), options.params), options.nativeOptions), {
16073
+ maxZoom: 12
16074
+ }));
16043
16075
  if (updateWmsParamsFromOpt) {
16044
16076
  const updateWmsParams = this.layer.updateWmsParams;
16045
16077
  this.layer.updateWmsParams = function(map) {
@@ -16050,6 +16082,13 @@ var LeafletMapAdapter = (function () {
16050
16082
  return this.layer;
16051
16083
  }
16052
16084
  }
16085
+ updateLayer(options) {
16086
+ if (this.layer) {
16087
+ const params = (options == null ? void 0 : options.params) || {};
16088
+ leafletSrcExports.Util.extend(this.layer.wmsParams, params);
16089
+ this.layer.update();
16090
+ }
16091
+ }
16053
16092
  }
16054
16093
  __publicField$1(ImageAdapter, "queue", imageQueue);
16055
16094
 
@@ -16173,13 +16212,12 @@ var LeafletMapAdapter = (function () {
16173
16212
  }
16174
16213
  }
16175
16214
  }
16176
- updateLayer() {
16215
+ updateLayer(options) {
16177
16216
  if (this.layer) {
16178
16217
  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);
16218
+ if (options == null ? void 0 : options.params) {
16219
+ this.layer.setUrl(updateUrlParams(currentUrl, options.params));
16220
+ }
16183
16221
  this.layer.redraw();
16184
16222
  }
16185
16223
  }
@@ -16497,7 +16535,7 @@ var LeafletMapAdapter = (function () {
16497
16535
  }
16498
16536
  }
16499
16537
  removeLayer(layer) {
16500
- layer && layer.remove && layer.remove();
16538
+ if (layer && layer.remove) layer.remove();
16501
16539
  }
16502
16540
  showLayer(layer) {
16503
16541
  if (this.map) {