@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,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.5; 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;
@@ -926,7 +926,7 @@ class GeoJsonAdapter extends BaseAdapter {
926
926
  if (feature) {
927
927
  return this._paint.preparePaint(__spreadValues$5(__spreadValues$5({}, PAINT), paint(feature)));
928
928
  } else {
929
- return this._paint.preparePaint(__spreadProps$3(__spreadValues$5({}, PAINT), { type: "path" }));
929
+ return this._paint.preparePaint(__spreadProps$4(__spreadValues$5({}, PAINT), { type: "path" }));
930
930
  }
931
931
  }
932
932
  };
@@ -1162,6 +1162,7 @@ var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key,
1162
1162
  var __publicField$2 = (obj, key, value) => __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
1163
1163
  class ImageLayer extends Layer {
1164
1164
  constructor(url, options) {
1165
+ var _a;
1165
1166
  super(options);
1166
1167
  __publicField$2(this, "defaultWmsParams", {
1167
1168
  service: "WMS",
@@ -1179,6 +1180,7 @@ class ImageLayer extends Layer {
1179
1180
  opacity: 1,
1180
1181
  isBack: false,
1181
1182
  minZoom: 0,
1183
+ maxZoom: void 0,
1182
1184
  pane: "tilePane",
1183
1185
  headers: null,
1184
1186
  withCredentials: false,
@@ -1202,7 +1204,11 @@ class ImageLayer extends Layer {
1202
1204
  }
1203
1205
  }
1204
1206
  Util.setOptions(this, opts);
1205
- this.wmsParams = Util.extend({}, this.defaultWmsParams, params);
1207
+ this.wmsParams = Util.extend(
1208
+ {},
1209
+ this.defaultWmsParams,
1210
+ (_a = params == null ? void 0 : params.params) != null ? _a : {}
1211
+ );
1206
1212
  }
1207
1213
  setParams(params) {
1208
1214
  Util.extend(this.wmsParams, params);
@@ -1350,6 +1356,8 @@ class ImageLayer extends Layer {
1350
1356
  }
1351
1357
 
1352
1358
  var __defProp$4 = Object.defineProperty;
1359
+ var __defProps$3 = Object.defineProperties;
1360
+ var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
1353
1361
  var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
1354
1362
  var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
1355
1363
  var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
@@ -1365,6 +1373,7 @@ var __spreadValues$4 = (a, b) => {
1365
1373
  }
1366
1374
  return a;
1367
1375
  };
1376
+ var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
1368
1377
  var __publicField$1 = (obj, key, value) => __defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
1369
1378
  class ImageAdapter extends BaseAdapter {
1370
1379
  constructor() {
@@ -1372,15 +1381,21 @@ class ImageAdapter extends BaseAdapter {
1372
1381
  __publicField$1(this, "layer");
1373
1382
  }
1374
1383
  addLayer(options) {
1384
+ var _a;
1375
1385
  const url = options && options.url;
1376
1386
  if (url) {
1377
- options = __spreadValues$4({ transparent: true }, options);
1378
1387
  const updateWmsParamsFromOpt = options.updateWmsParams;
1379
- this.layer = new ImageLayer(url, __spreadValues$4(__spreadValues$4(__spreadValues$4({
1388
+ this.layer = new ImageLayer(url, __spreadProps$3(__spreadValues$4(__spreadValues$4(__spreadValues$4({
1380
1389
  pane: this.pane,
1381
1390
  headers: options.headers,
1382
1391
  setViewDelay: options.setViewDelay
1383
- }, options), options.params), options.nativeOptions));
1392
+ }, __spreadProps$3(__spreadValues$4({
1393
+ transparent: true
1394
+ }, options), {
1395
+ opacity: (_a = options.opacity) != null ? _a : void 0
1396
+ })), options.params), options.nativeOptions), {
1397
+ maxZoom: 12
1398
+ }));
1384
1399
  if (updateWmsParamsFromOpt) {
1385
1400
  const updateWmsParams = this.layer.updateWmsParams;
1386
1401
  this.layer.updateWmsParams = function(map) {
@@ -1391,6 +1406,13 @@ class ImageAdapter extends BaseAdapter {
1391
1406
  return this.layer;
1392
1407
  }
1393
1408
  }
1409
+ updateLayer(options) {
1410
+ if (this.layer) {
1411
+ const params = (options == null ? void 0 : options.params) || {};
1412
+ Util.extend(this.layer.wmsParams, params);
1413
+ this.layer.update();
1414
+ }
1415
+ }
1394
1416
  }
1395
1417
  __publicField$1(ImageAdapter, "queue", imageQueue);
1396
1418
 
@@ -1532,13 +1554,12 @@ class TileAdapter extends BaseAdapter {
1532
1554
  }
1533
1555
  }
1534
1556
  }
1535
- updateLayer() {
1557
+ updateLayer(options) {
1536
1558
  if (this.layer) {
1537
1559
  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);
1560
+ if (options == null ? void 0 : options.params) {
1561
+ this.layer.setUrl(updateUrlParams(currentUrl, options.params));
1562
+ }
1542
1563
  this.layer.redraw();
1543
1564
  }
1544
1565
  }