@nextgis/leaflet-map-adapter 3.0.0-alpha.5 → 3.1.0

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.5; author: NextGIS */
1
+ /** Bundle of @nextgis/leaflet-map-adapter; version: 3.1.0; author: NextGIS */
2
2
  import { EventEmitter } from 'events';
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, updateUrlParams } from '@nextgis/utils';
3
+ import { Control, DomEvent, GeoJSON, DivIcon, Marker, CircleMarker, FeatureGroup, ImageOverlay as ImageOverlay$1, Layer, Util, GridLayer, DomUtil, TileLayer as TileLayer$1, Map, latLngBounds, latLng } from 'leaflet';
4
+ import { defined, debounce as debounce$1, isObject, 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,16 +1164,9 @@ 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) {
1165
- var _a;
1166
1167
  super(options);
1167
1168
  __publicField$2(this, "defaultWmsParams", {
1168
- service: "WMS",
1169
- request: "GetMap",
1170
- version: "1.1.1",
1171
- layers: "",
1172
- styles: "",
1173
- format: "image/jpeg",
1174
- transparent: false
1169
+ request: "GetMap"
1175
1170
  });
1176
1171
  __publicField$2(this, "options", {
1177
1172
  crs: null,
@@ -1180,6 +1175,7 @@ class ImageLayer extends Layer {
1180
1175
  opacity: 1,
1181
1176
  isBack: false,
1182
1177
  minZoom: 0,
1178
+ maxZoom: void 0,
1183
1179
  pane: "tilePane",
1184
1180
  headers: null,
1185
1181
  withCredentials: false,
@@ -1196,18 +1192,21 @@ class ImageLayer extends Layer {
1196
1192
  const opts = {};
1197
1193
  let opt;
1198
1194
  for (opt in options) {
1195
+ const val = options[opt];
1199
1196
  if (opt in this.options) {
1200
- opts[opt] = options[opt];
1201
- } else {
1202
- params[opt] = options[opt];
1197
+ opts[opt] = val;
1198
+ }
1199
+ }
1200
+ if (options.params) {
1201
+ for (const param in options.params) {
1202
+ const val = options.params[param];
1203
+ if (!isObject(val) && !Array.isArray(val) && typeof val !== "function") {
1204
+ params[param] = val;
1205
+ }
1203
1206
  }
1204
1207
  }
1205
1208
  Util.setOptions(this, opts);
1206
- this.wmsParams = Util.extend(
1207
- {},
1208
- this.defaultWmsParams,
1209
- (_a = params == null ? void 0 : params.params) != null ? _a : {}
1210
- );
1209
+ this.wmsParams = Util.extend({}, this.defaultWmsParams, params);
1211
1210
  }
1212
1211
  setParams(params) {
1213
1212
  Util.extend(this.wmsParams, params);
@@ -1332,9 +1331,7 @@ class ImageLayer extends Layer {
1332
1331
  size.x = Math.ceil(size.x * factor);
1333
1332
  size.y = Math.ceil(size.y * factor);
1334
1333
  }
1335
- const wmsVersion = parseFloat(this.wmsParams.version);
1336
1334
  const crs = this.options.crs || map.options.crs;
1337
- const projectionKey = wmsVersion >= 1.3 ? "crs" : "srs";
1338
1335
  if (crs) {
1339
1336
  const nw = crs.project(bounds.getNorthWest());
1340
1337
  const se = crs.project(bounds.getSouthEast());
@@ -1342,8 +1339,7 @@ class ImageLayer extends Layer {
1342
1339
  width: size.x,
1343
1340
  height: size.y
1344
1341
  };
1345
- params[projectionKey] = crs.code;
1346
- params.bbox = (wmsVersion >= 1.3 && crs === CRS.EPSG4326 ? [se.y, nw.x, nw.y, se.x] : [nw.x, se.y, se.x, nw.y]).join(",");
1342
+ params.bbox = [nw.x, se.y, se.x, nw.y];
1347
1343
  Util.extend(this.wmsParams, params);
1348
1344
  }
1349
1345
  }
@@ -1355,6 +1351,8 @@ class ImageLayer extends Layer {
1355
1351
  }
1356
1352
 
1357
1353
  var __defProp$4 = Object.defineProperty;
1354
+ var __defProps$3 = Object.defineProperties;
1355
+ var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
1358
1356
  var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
1359
1357
  var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
1360
1358
  var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
@@ -1370,6 +1368,7 @@ var __spreadValues$4 = (a, b) => {
1370
1368
  }
1371
1369
  return a;
1372
1370
  };
1371
+ var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
1373
1372
  var __publicField$1 = (obj, key, value) => __defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
1374
1373
  class ImageAdapter extends BaseAdapter {
1375
1374
  constructor() {
@@ -1377,15 +1376,19 @@ class ImageAdapter extends BaseAdapter {
1377
1376
  __publicField$1(this, "layer");
1378
1377
  }
1379
1378
  addLayer(options) {
1379
+ var _a;
1380
1380
  const url = options && options.url;
1381
1381
  if (url) {
1382
- options = __spreadValues$4({ transparent: true }, options);
1383
1382
  const updateWmsParamsFromOpt = options.updateWmsParams;
1384
1383
  this.layer = new ImageLayer(url, __spreadValues$4(__spreadValues$4(__spreadValues$4({
1385
1384
  pane: this.pane,
1386
1385
  headers: options.headers,
1387
1386
  setViewDelay: options.setViewDelay
1388
- }, options), options.params), options.nativeOptions));
1387
+ }, __spreadProps$3(__spreadValues$4({
1388
+ transparent: true
1389
+ }, options), {
1390
+ opacity: (_a = options.opacity) != null ? _a : void 0
1391
+ })), options.params), options.nativeOptions));
1389
1392
  if (updateWmsParamsFromOpt) {
1390
1393
  const updateWmsParams = this.layer.updateWmsParams;
1391
1394
  this.layer.updateWmsParams = function(map) {
@@ -1867,7 +1870,7 @@ const _LeafletMapAdapter = class _LeafletMapAdapter {
1867
1870
  }
1868
1871
  }
1869
1872
  removeLayer(layer) {
1870
- layer && layer.remove && layer.remove();
1873
+ if (layer && layer.remove) layer.remove();
1871
1874
  }
1872
1875
  showLayer(layer) {
1873
1876
  if (this.map) {