@nextgis/ngw-map 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-map; version: 3.0.0-alpha.17; author: NextGIS */
1
+ /** Bundle of @nextgis/ngw-map; version: 3.0.0-alpha.18; author: NextGIS */
2
2
  'use strict';
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
@@ -1,4 +1,4 @@
1
- /** Bundle of @nextgis/ngw-map; version: 3.0.0-alpha.17; author: NextGIS */
1
+ /** Bundle of @nextgis/ngw-map; version: 3.0.0-alpha.18; author: NextGIS */
2
2
  const svgPath = {
3
3
  brill: '<path d="m6 0-5 6 5 6 5-6z"/>',
4
4
  circle: '<circle cx="6" cy="6" r="6"/>',
@@ -1065,7 +1065,7 @@ function unwrapListeners(arr) {
1065
1065
 
1066
1066
  var pkg = {
1067
1067
  name: "@nextgis/ngw-connector",
1068
- version: "3.0.0-alpha.17",
1068
+ version: "3.0.0-alpha.18",
1069
1069
  _priority: 12,
1070
1070
  description: "A lightweight HTTP client optimized for use with NextGIS Web API",
1071
1071
  main: "index.js",
@@ -4285,6 +4285,10 @@ class WebmapLayerOpacityPropertyHandler extends BaseProperty {
4285
4285
  }
4286
4286
  }
4287
4287
 
4288
+ function createLayerSymbolParam(resourceId, intervals) {
4289
+ return { [`symbols[${resourceId}]`]: intervals.join(",") || void 0 };
4290
+ }
4291
+
4288
4292
  var __defProp$r = Object.defineProperty;
4289
4293
  var __defProps$c = Object.defineProperties;
4290
4294
  var __getOwnPropDescs$c = Object.getOwnPropertyDescriptors;
@@ -4353,7 +4357,9 @@ class Legend {
4353
4357
  this.connector = connector;
4354
4358
  this.layer = layer;
4355
4359
  this.layerId = layerId;
4356
- this.legend = this.createLegend(legend);
4360
+ if (legend) {
4361
+ this.legend = this.createLegend(legend);
4362
+ }
4357
4363
  this.resourceId = resourceId;
4358
4364
  this.webMap = webMap;
4359
4365
  this.onSymbolRenderChange = onSymbolRenderChange;
@@ -4362,12 +4368,13 @@ class Legend {
4362
4368
  this.layerId = String(layer.id);
4363
4369
  this.layer = layer;
4364
4370
  }
4365
- create(options) {
4366
- return __async$k(this, null, function* () {
4371
+ create() {
4372
+ return __async$k(this, arguments, function* (options = {}) {
4367
4373
  if (this.connector) {
4368
4374
  const ngwLegend = yield this.connector.route("render.legend_symbols", {
4369
4375
  id: this.resourceId
4370
4376
  }).get(__spreadValues$j({}, options));
4377
+ this.legend = ngwLegend;
4371
4378
  return this.createLegend(ngwLegend);
4372
4379
  }
4373
4380
  });
@@ -4381,15 +4388,17 @@ class Legend {
4381
4388
  }));
4382
4389
  }
4383
4390
  setSymbolRender(symbolIndex, status) {
4384
- const legendItem = this.legend.find((l) => l.index === symbolIndex);
4385
- if (legendItem) {
4386
- const render = legendItem.render;
4387
- if (render !== status) {
4388
- legendItem.render = status;
4389
- const newSymbols = this.legend.filter((l) => l.render).map((l) => l.index);
4390
- this.setLegendSymbol(newSymbols);
4391
- if (this.onSymbolRenderChange) {
4392
- this.onSymbolRenderChange(newSymbols);
4391
+ if (this.legend) {
4392
+ const legendItem = this.legend.find((l) => l.index === symbolIndex);
4393
+ if (legendItem) {
4394
+ const render = legendItem.render;
4395
+ if (render !== status) {
4396
+ legendItem.render = status;
4397
+ const newSymbols = this.legend.filter((l) => l.render).map((l) => l.index);
4398
+ this.setLegendSymbol(newSymbols);
4399
+ if (this.onSymbolRenderChange) {
4400
+ this.onSymbolRenderChange(newSymbols);
4401
+ }
4393
4402
  }
4394
4403
  }
4395
4404
  }
@@ -4401,9 +4410,7 @@ class Legend {
4401
4410
  }
4402
4411
  if (this.layer.updateLayer) {
4403
4412
  this.layer.updateLayer({
4404
- params: {
4405
- [`symbols[${this.resourceId}]`]: intervals.join(",") || void 0
4406
- }
4413
+ params: __spreadValues$j({}, createLayerSymbolParam(this.resourceId, intervals))
4407
4414
  });
4408
4415
  }
4409
4416
  if (intervals.length) {
@@ -4556,13 +4563,10 @@ const _NgwWebmapItem = class _NgwWebmapItem extends Item {
4556
4563
  if (connector && "resourceId" in this.item) {
4557
4564
  const resourceId = Number(this.item.resourceId);
4558
4565
  if (this.item.item_type === "layer") {
4559
- const ngwLegend = yield connector.route("render.legend_symbols", {
4560
- id: resourceId
4561
- }).get(__spreadValues$i({}, options));
4562
- if (this.layer && ngwLegend) {
4566
+ if (this.layer) {
4563
4567
  const legend = new Legend({
4568
+ connector: this.connector,
4564
4569
  layerId: id,
4565
- legend: ngwLegend,
4566
4570
  layer: this.layer,
4567
4571
  resourceId,
4568
4572
  webMap: this.webMap,
@@ -4575,6 +4579,7 @@ const _NgwWebmapItem = class _NgwWebmapItem extends Item {
4575
4579
  });
4576
4580
  }
4577
4581
  });
4582
+ yield legend.create(options);
4578
4583
  return [legend];
4579
4584
  }
4580
4585
  }