@nextgis/ngw-leaflet 3.0.0-alpha.18 → 3.0.0-alpha.19

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/ngw-leaflet; version: 3.0.0-alpha.17; author: NextGIS */
1
+ /** Bundle of @nextgis/ngw-leaflet; version: 3.0.0-alpha.18; author: NextGIS */
2
2
  import LeafletMapAdapter from '@nextgis/leaflet-map-adapter';
3
3
  import { NgwMap } from '@nextgis/ngw-map';
4
4
  import { Icon } from 'leaflet';
@@ -1,4 +1,4 @@
1
- /** Bundle of @nextgis/ngw-leaflet; version: 3.0.0-alpha.17; author: NextGIS */
1
+ /** Bundle of @nextgis/ngw-leaflet; version: 3.0.0-alpha.18; author: NextGIS */
2
2
  var NgwLeaflet = (function () {
3
3
  'use strict';
4
4
 
@@ -17041,7 +17041,6 @@ var NgwLeaflet = (function () {
17041
17041
  var __publicField$D = (obj, key, value) => __defNormalProp$U(obj, typeof key !== "symbol" ? key + "" : key, value);
17042
17042
  class ImageLayer extends leafletSrcExports.Layer {
17043
17043
  constructor(url, options) {
17044
- var _a;
17045
17044
  super(options);
17046
17045
  __publicField$D(this, "defaultWmsParams", {
17047
17046
  service: "WMS",
@@ -17076,18 +17075,21 @@ var NgwLeaflet = (function () {
17076
17075
  const opts = {};
17077
17076
  let opt;
17078
17077
  for (opt in options) {
17078
+ const val = options[opt];
17079
17079
  if (opt in this.options) {
17080
- opts[opt] = options[opt];
17081
- } else if (!isObject$1(options[opt])) {
17082
- params[opt] = options[opt];
17080
+ opts[opt] = val;
17081
+ }
17082
+ }
17083
+ if (options.params) {
17084
+ for (const param in options.params) {
17085
+ const val = options.params[param];
17086
+ if (!isObject$1(val) && !Array.isArray(val) && typeof val !== "function") {
17087
+ params[param] = val;
17088
+ }
17083
17089
  }
17084
17090
  }
17085
17091
  leafletSrcExports.Util.setOptions(this, opts);
17086
- this.wmsParams = leafletSrcExports.Util.extend(
17087
- {},
17088
- this.defaultWmsParams,
17089
- (_a = params == null ? void 0 : params.params) != null ? _a : {}
17090
- );
17092
+ this.wmsParams = leafletSrcExports.Util.extend({}, this.defaultWmsParams, params);
17091
17093
  }
17092
17094
  setParams(params) {
17093
17095
  leafletSrcExports.Util.extend(this.wmsParams, params);
@@ -18191,7 +18193,7 @@ var NgwLeaflet = (function () {
18191
18193
 
18192
18194
  var pkg = {
18193
18195
  name: "@nextgis/ngw-connector",
18194
- version: "3.0.0-alpha.17",
18196
+ version: "3.0.0-alpha.18",
18195
18197
  _priority: 12,
18196
18198
  description: "A lightweight HTTP client optimized for use with NextGIS Web API",
18197
18199
  main: "index.js",
@@ -21317,6 +21319,10 @@ var NgwLeaflet = (function () {
21317
21319
  }
21318
21320
  }
21319
21321
 
21322
+ function createLayerSymbolParam(resourceId, intervals) {
21323
+ return { [`symbols[${resourceId}]`]: intervals.join(",") || void 0 };
21324
+ }
21325
+
21320
21326
  var __defProp$p = Object.defineProperty;
21321
21327
  var __defProps$d = Object.defineProperties;
21322
21328
  var __getOwnPropDescs$d = Object.getOwnPropertyDescriptors;
@@ -21385,7 +21391,9 @@ var NgwLeaflet = (function () {
21385
21391
  this.connector = connector;
21386
21392
  this.layer = layer;
21387
21393
  this.layerId = layerId;
21388
- this.legend = this.createLegend(legend);
21394
+ if (legend) {
21395
+ this.legend = this.createLegend(legend);
21396
+ }
21389
21397
  this.resourceId = resourceId;
21390
21398
  this.webMap = webMap;
21391
21399
  this.onSymbolRenderChange = onSymbolRenderChange;
@@ -21394,12 +21402,13 @@ var NgwLeaflet = (function () {
21394
21402
  this.layerId = String(layer.id);
21395
21403
  this.layer = layer;
21396
21404
  }
21397
- create(options) {
21398
- return __async$j(this, null, function* () {
21405
+ create() {
21406
+ return __async$j(this, arguments, function* (options = {}) {
21399
21407
  if (this.connector) {
21400
21408
  const ngwLegend = yield this.connector.route("render.legend_symbols", {
21401
21409
  id: this.resourceId
21402
21410
  }).get(__spreadValues$h({}, options));
21411
+ this.legend = ngwLegend;
21403
21412
  return this.createLegend(ngwLegend);
21404
21413
  }
21405
21414
  });
@@ -21413,15 +21422,17 @@ var NgwLeaflet = (function () {
21413
21422
  }));
21414
21423
  }
21415
21424
  setSymbolRender(symbolIndex, status) {
21416
- const legendItem = this.legend.find((l) => l.index === symbolIndex);
21417
- if (legendItem) {
21418
- const render = legendItem.render;
21419
- if (render !== status) {
21420
- legendItem.render = status;
21421
- const newSymbols = this.legend.filter((l) => l.render).map((l) => l.index);
21422
- this.setLegendSymbol(newSymbols);
21423
- if (this.onSymbolRenderChange) {
21424
- this.onSymbolRenderChange(newSymbols);
21425
+ if (this.legend) {
21426
+ const legendItem = this.legend.find((l) => l.index === symbolIndex);
21427
+ if (legendItem) {
21428
+ const render = legendItem.render;
21429
+ if (render !== status) {
21430
+ legendItem.render = status;
21431
+ const newSymbols = this.legend.filter((l) => l.render).map((l) => l.index);
21432
+ this.setLegendSymbol(newSymbols);
21433
+ if (this.onSymbolRenderChange) {
21434
+ this.onSymbolRenderChange(newSymbols);
21435
+ }
21425
21436
  }
21426
21437
  }
21427
21438
  }
@@ -21433,9 +21444,7 @@ var NgwLeaflet = (function () {
21433
21444
  }
21434
21445
  if (this.layer.updateLayer) {
21435
21446
  this.layer.updateLayer({
21436
- params: {
21437
- [`symbols[${this.resourceId}]`]: intervals.join(",") || void 0
21438
- }
21447
+ params: __spreadValues$h({}, createLayerSymbolParam(this.resourceId, intervals))
21439
21448
  });
21440
21449
  }
21441
21450
  if (intervals.length) {
@@ -21588,13 +21597,10 @@ var NgwLeaflet = (function () {
21588
21597
  if (connector && "resourceId" in this.item) {
21589
21598
  const resourceId = Number(this.item.resourceId);
21590
21599
  if (this.item.item_type === "layer") {
21591
- const ngwLegend = yield connector.route("render.legend_symbols", {
21592
- id: resourceId
21593
- }).get(__spreadValues$g({}, options));
21594
- if (this.layer && ngwLegend) {
21600
+ if (this.layer) {
21595
21601
  const legend = new Legend({
21602
+ connector: this.connector,
21596
21603
  layerId: id,
21597
- legend: ngwLegend,
21598
21604
  layer: this.layer,
21599
21605
  resourceId,
21600
21606
  webMap: this.webMap,
@@ -21607,6 +21613,7 @@ var NgwLeaflet = (function () {
21607
21613
  });
21608
21614
  }
21609
21615
  });
21616
+ yield legend.create(options);
21610
21617
  return [legend];
21611
21618
  }
21612
21619
  }