@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,7 +1,7 @@
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
  import { EventEmitter } from 'events';
3
3
  import { Control, DomEvent, GeoJSON, DivIcon, Marker, CircleMarker, FeatureGroup, ImageOverlay as ImageOverlay$1, Layer, Util, CRS, GridLayer, DomUtil, TileLayer as TileLayer$1, Map, latLngBounds, latLng } from 'leaflet';
4
- import { defined, debounce as debounce$1 } from '@nextgis/utils';
4
+ import { defined, debounce as debounce$1, updateUrlParams } from '@nextgis/utils';
5
5
  import { isPaintCallback, isPaint } from '@nextgis/paint';
6
6
  import Queue from '@nextgis/queue';
7
7
 
@@ -349,8 +349,8 @@ class GeoJsonEvents {
349
349
  }
350
350
 
351
351
  var __defProp$8 = Object.defineProperty;
352
- var __defProps$4 = Object.defineProperties;
353
- var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
352
+ var __defProps$5 = Object.defineProperties;
353
+ var __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors;
354
354
  var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
355
355
  var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
356
356
  var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
@@ -366,7 +366,7 @@ var __spreadValues$6 = (a, b) => {
366
366
  }
367
367
  return a;
368
368
  };
369
- var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
369
+ var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
370
370
  var __objRest$2 = (source, exclude) => {
371
371
  var target = {};
372
372
  for (var prop in source)
@@ -461,7 +461,7 @@ class GeoJsonPaint {
461
461
  if (html) {
462
462
  element.innerHTML = html;
463
463
  }
464
- const divIcon = new DivIcon(__spreadProps$4(__spreadValues$6({
464
+ const divIcon = new DivIcon(__spreadProps$5(__spreadValues$6({
465
465
  className: ""
466
466
  }, toLIconOpt), {
467
467
  html: element
@@ -510,8 +510,8 @@ class GeoJsonPaint {
510
510
  }
511
511
 
512
512
  var __defProp$7 = Object.defineProperty;
513
- var __defProps$3 = Object.defineProperties;
514
- var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
513
+ var __defProps$4 = Object.defineProperties;
514
+ var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
515
515
  var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
516
516
  var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
517
517
  var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
@@ -527,7 +527,7 @@ var __spreadValues$5 = (a, b) => {
527
527
  }
528
528
  return a;
529
529
  };
530
- var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
530
+ var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
531
531
  var __publicField$4 = (obj, key, value) => __defNormalProp$7(obj, typeof key !== "symbol" ? key + "" : key, value);
532
532
  var __async = (__this, __arguments, generator) => {
533
533
  return new Promise((resolve, reject) => {
@@ -576,7 +576,7 @@ class GeoJsonAdapter extends BaseAdapter {
576
576
  addLayer(options) {
577
577
  Object.assign(this.options, options);
578
578
  this.paint = options.paint;
579
- this.layer = new FeatureGroup([], __spreadProps$3(__spreadValues$5({}, options.nativeOptions), {
579
+ this.layer = new FeatureGroup([], __spreadProps$4(__spreadValues$5({}, options.nativeOptions), {
580
580
  pane: this.pane
581
581
  }));
582
582
  this.selectedPaint = options.selectedPaint;
@@ -875,13 +875,15 @@ class GeoJsonAdapter extends BaseAdapter {
875
875
  const unselectOnClose = (_b = (_a = this.options.popupOptions) == null ? void 0 : _a.unselectOnClose) != null ? _b : true;
876
876
  if (unselectOnClose) {
877
877
  const p = layer.getPopup();
878
- p && p.once(
879
- "remove",
880
- () => {
881
- close();
882
- },
883
- this
884
- );
878
+ if (p) {
879
+ p.once(
880
+ "remove",
881
+ () => {
882
+ close();
883
+ },
884
+ this
885
+ );
886
+ }
885
887
  }
886
888
  this._openedPopup.push([popup, _closeHandlers, def]);
887
889
  popup.openPopup(latLng);
@@ -926,7 +928,7 @@ class GeoJsonAdapter extends BaseAdapter {
926
928
  if (feature) {
927
929
  return this._paint.preparePaint(__spreadValues$5(__spreadValues$5({}, PAINT), paint(feature)));
928
930
  } else {
929
- return this._paint.preparePaint(__spreadProps$3(__spreadValues$5({}, PAINT), { type: "path" }));
931
+ return this._paint.preparePaint(__spreadProps$4(__spreadValues$5({}, PAINT), { type: "path" }));
930
932
  }
931
933
  }
932
934
  };
@@ -1162,6 +1164,7 @@ var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key,
1162
1164
  var __publicField$2 = (obj, key, value) => __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
1163
1165
  class ImageLayer extends Layer {
1164
1166
  constructor(url, options) {
1167
+ var _a;
1165
1168
  super(options);
1166
1169
  __publicField$2(this, "defaultWmsParams", {
1167
1170
  service: "WMS",
@@ -1179,6 +1182,7 @@ class ImageLayer extends Layer {
1179
1182
  opacity: 1,
1180
1183
  isBack: false,
1181
1184
  minZoom: 0,
1185
+ maxZoom: void 0,
1182
1186
  pane: "tilePane",
1183
1187
  headers: null,
1184
1188
  withCredentials: false,
@@ -1202,7 +1206,11 @@ class ImageLayer extends Layer {
1202
1206
  }
1203
1207
  }
1204
1208
  Util.setOptions(this, opts);
1205
- this.wmsParams = Util.extend({}, this.defaultWmsParams, params);
1209
+ this.wmsParams = Util.extend(
1210
+ {},
1211
+ this.defaultWmsParams,
1212
+ (_a = params == null ? void 0 : params.params) != null ? _a : {}
1213
+ );
1206
1214
  }
1207
1215
  setParams(params) {
1208
1216
  Util.extend(this.wmsParams, params);
@@ -1350,6 +1358,8 @@ class ImageLayer extends Layer {
1350
1358
  }
1351
1359
 
1352
1360
  var __defProp$4 = Object.defineProperty;
1361
+ var __defProps$3 = Object.defineProperties;
1362
+ var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
1353
1363
  var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
1354
1364
  var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
1355
1365
  var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
@@ -1365,6 +1375,7 @@ var __spreadValues$4 = (a, b) => {
1365
1375
  }
1366
1376
  return a;
1367
1377
  };
1378
+ var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
1368
1379
  var __publicField$1 = (obj, key, value) => __defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
1369
1380
  class ImageAdapter extends BaseAdapter {
1370
1381
  constructor() {
@@ -1372,15 +1383,21 @@ class ImageAdapter extends BaseAdapter {
1372
1383
  __publicField$1(this, "layer");
1373
1384
  }
1374
1385
  addLayer(options) {
1386
+ var _a;
1375
1387
  const url = options && options.url;
1376
1388
  if (url) {
1377
- options = __spreadValues$4({ transparent: true }, options);
1378
1389
  const updateWmsParamsFromOpt = options.updateWmsParams;
1379
- this.layer = new ImageLayer(url, __spreadValues$4(__spreadValues$4(__spreadValues$4({
1390
+ this.layer = new ImageLayer(url, __spreadProps$3(__spreadValues$4(__spreadValues$4(__spreadValues$4({
1380
1391
  pane: this.pane,
1381
1392
  headers: options.headers,
1382
1393
  setViewDelay: options.setViewDelay
1383
- }, options), options.params), options.nativeOptions));
1394
+ }, __spreadProps$3(__spreadValues$4({
1395
+ transparent: true
1396
+ }, options), {
1397
+ opacity: (_a = options.opacity) != null ? _a : void 0
1398
+ })), options.params), options.nativeOptions), {
1399
+ maxZoom: 12
1400
+ }));
1384
1401
  if (updateWmsParamsFromOpt) {
1385
1402
  const updateWmsParams = this.layer.updateWmsParams;
1386
1403
  this.layer.updateWmsParams = function(map) {
@@ -1391,6 +1408,13 @@ class ImageAdapter extends BaseAdapter {
1391
1408
  return this.layer;
1392
1409
  }
1393
1410
  }
1411
+ updateLayer(options) {
1412
+ if (this.layer) {
1413
+ const params = (options == null ? void 0 : options.params) || {};
1414
+ Util.extend(this.layer.wmsParams, params);
1415
+ this.layer.update();
1416
+ }
1417
+ }
1394
1418
  }
1395
1419
  __publicField$1(ImageAdapter, "queue", imageQueue);
1396
1420
 
@@ -1532,13 +1556,12 @@ class TileAdapter extends BaseAdapter {
1532
1556
  }
1533
1557
  }
1534
1558
  }
1535
- updateLayer() {
1559
+ updateLayer(options) {
1536
1560
  if (this.layer) {
1537
1561
  const currentUrl = this.layer._url;
1538
- const timestamp = (/* @__PURE__ */ new Date()).getTime();
1539
- const separator = currentUrl.includes("?") ? "&" : "?";
1540
- const newUrl = currentUrl.replace(/(\?|&)timestamp=\d*/g, "") + separator + `timestamp=${timestamp}`;
1541
- this.layer.setUrl(newUrl);
1562
+ if (options == null ? void 0 : options.params) {
1563
+ this.layer.setUrl(updateUrlParams(currentUrl, options.params));
1564
+ }
1542
1565
  this.layer.redraw();
1543
1566
  }
1544
1567
  }
@@ -1856,7 +1879,7 @@ const _LeafletMapAdapter = class _LeafletMapAdapter {
1856
1879
  }
1857
1880
  }
1858
1881
  removeLayer(layer) {
1859
- layer && layer.remove && layer.remove();
1882
+ if (layer && layer.remove) layer.remove();
1860
1883
  }
1861
1884
  showLayer(layer) {
1862
1885
  if (this.map) {