@nextgis/ngw-map 1.15.1 → 1.16.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,4 +1,4 @@
1
- /** Bundle of @nextgis/ngw-map; version: 1.15.1; author: NextGIS */
1
+ /** Bundle of @nextgis/ngw-map; version: 1.16.0; author: NextGIS */
2
2
  import { EventEmitter } from 'events';
3
3
  import CancelablePromise from '@nextgis/cancelable-promise';
4
4
  import { deepmerge, isObject, defined, deprecatedWarn } from '@nextgis/utils';
@@ -1,4 +1,4 @@
1
- /** Bundle of @nextgis/ngw-map; version: 1.15.1; author: NextGIS */
1
+ /** Bundle of @nextgis/ngw-map; version: 1.16.0; author: NextGIS */
2
2
  var NgwMap = (function (exports) {
3
3
  'use strict';
4
4
 
@@ -1525,6 +1525,24 @@ var NgwMap = (function (exports) {
1525
1525
  return mask;
1526
1526
  };
1527
1527
  }
1528
+ function expressionCallback(paint, defaultPaint, getPaintFunctions) {
1529
+ var expressionCallback = createExpressionCallback(paint);
1530
+ if (expressionCallback) {
1531
+ var expressionPaintCb = function (feature) {
1532
+ return preparePaint(expressionCallback(feature), defaultPaint, getPaintFunctions);
1533
+ };
1534
+ expressionPaintCb.paint = paint;
1535
+ return expressionPaintCb;
1536
+ }
1537
+ var newPaint = __assign({}, defaultPaint);
1538
+ newPaint = __assign(__assign({}, newPaint), paint);
1539
+ newPaint.fill = newPaint.fill !== undefined ? newPaint.fill : true;
1540
+ newPaint.stroke =
1541
+ newPaint.stroke !== undefined
1542
+ ? newPaint.stroke
1543
+ : !newPaint.fill || !!(newPaint.strokeColor || newPaint.strokeOpacity);
1544
+ return newPaint;
1545
+ }
1528
1546
  function preparePaint(paint, defaultPaint, getPaintFunctions) {
1529
1547
  if (!paint) {
1530
1548
  throw new Error('paint is empty');
@@ -1554,20 +1572,7 @@ var NgwMap = (function (exports) {
1554
1572
  return paint;
1555
1573
  }
1556
1574
  else {
1557
- var expressionCallback_1 = createExpressionCallback(paint);
1558
- if (expressionCallback_1) {
1559
- var expressionPaintCb = function (feature) {
1560
- return preparePaint(expressionCallback_1(feature), defaultPaint, getPaintFunctions);
1561
- };
1562
- expressionPaintCb.paint = paint;
1563
- return expressionPaintCb;
1564
- }
1565
- newPaint = __assign(__assign({}, newPaint), paint);
1566
- newPaint.fill = newPaint.fill !== undefined ? newPaint.fill : true;
1567
- newPaint.stroke =
1568
- newPaint.stroke !== undefined
1569
- ? newPaint.stroke
1570
- : !newPaint.fill || !!(newPaint.strokeColor || newPaint.strokeOpacity);
1575
+ newPaint = expressionCallback(paint, defaultPaint, getPaintFunctions);
1571
1576
  }
1572
1577
  if (isPaintCallback(newPaint)) {
1573
1578
  return newPaint;
@@ -6645,10 +6650,12 @@ var NgwMap = (function (exports) {
6645
6650
  };
6646
6651
  if (item.item_type === 'group' || item.item_type === 'root') {
6647
6652
  if (item.children && item.children.length) {
6648
- this.getChildren(item).forEach(function (x) {
6649
- var children = new NgwWebmapItem(_this.webMap, x, _this.options, _this.connector, _this);
6650
- _this.tree.addChild(children);
6651
- });
6653
+ var children = this.getChildren(item);
6654
+ for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
6655
+ var x = children_1[_i];
6656
+ var children_2 = new this.constructor(this.webMap, x, this.options, this.connector, this);
6657
+ this.tree.addChild(children_2);
6658
+ }
6652
6659
  }
6653
6660
  return Promise.resolve();
6654
6661
  }
@@ -6689,7 +6696,7 @@ var NgwMap = (function (exports) {
6689
6696
  headers: this.options.headers,
6690
6697
  crossOrigin: this.options.crossOrigin,
6691
6698
  setViewDelay: this.options.setViewDelay,
6692
- params: { resource: this.item.resourceId },
6699
+ params: { resource: this.item.resourceId, item: this.item },
6693
6700
  };
6694
6701
  if (this.options.order) {
6695
6702
  var subOrder = this.options.drawOrderEnabled && 'draw_order_position' in item
@@ -6700,6 +6707,9 @@ var NgwMap = (function (exports) {
6700
6707
  var subLevel = String(subOrder).padStart(4, '0');
6701
6708
  options.order = Number((this.options.order | 0) + '.' + subLevel);
6702
6709
  }
6710
+ if (this.options.popupOptions) {
6711
+ options.popupOptions = this.options.popupOptions;
6712
+ }
6703
6713
  if (item.item_type === 'layer') {
6704
6714
  var _a = this._getZoomRange(item), maxZoom = _a.maxZoom, minZoom = _a.minZoom;
6705
6715
  objectAssign(options, {
@@ -6747,8 +6757,8 @@ var NgwMap = (function (exports) {
6747
6757
  };
6748
6758
  NgwWebmapItem.prototype._sumUp = function (children, totalValue) {
6749
6759
  if (totalValue === void 0) { totalValue = 0; }
6750
- for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
6751
- var child = children_1[_i];
6760
+ for (var _i = 0, children_3 = children; _i < children_3.length; _i++) {
6761
+ var child = children_3[_i];
6752
6762
  if (child.item_type === 'layer') {
6753
6763
  totalValue += 1;
6754
6764
  child.draw_order_position = child.draw_order_position || totalValue;
@@ -7055,8 +7065,6 @@ var NgwMap = (function (exports) {
7055
7065
  this._extent &&
7056
7066
  extentConstrained) {
7057
7067
  this.options.webMap.setView({ maxBounds: this._extent });
7058
- // @ts-ignore
7059
- window.webmap = this.options.webMap;
7060
7068
  }
7061
7069
  return [2 /*return*/, this.layer];
7062
7070
  }
@@ -7229,6 +7237,7 @@ var NgwMap = (function (exports) {
7229
7237
  options.minZoom = _this.options.minZoom;
7230
7238
  options.maxZoom = _this.options.maxZoom;
7231
7239
  options.drawOrderEnabled = webmap_1.draw_order_enabled;
7240
+ options.popupOptions = _this.options.popupOptions;
7232
7241
  var layer = new _this.NgwWebmapItem(_this.options.webMap, webmap_1.root_item, options, _this.options.connector);
7233
7242
  layer.emitter.on('init', function () { return resolve(layer); });
7234
7243
  })];
@@ -7359,30 +7368,34 @@ var NgwMap = (function (exports) {
7359
7368
  };
7360
7369
  NgwWebmapLayerAdapter.prototype._getWebMapIds = function () {
7361
7370
  return __awaiter(this, void 0, void 0, function () {
7362
- var webMapItem, layers, promises_1, ids;
7363
- var _this = this;
7371
+ var webMapItem, layers, promises, _loop_2, this_2, _i, layers_1, x, ids;
7364
7372
  return __generator(this, function (_a) {
7365
7373
  switch (_a.label) {
7366
7374
  case 0:
7367
7375
  webMapItem = this.layer;
7368
7376
  if (!(webMapItem && webMapItem.item.item_type === 'root')) return [3 /*break*/, 2];
7369
7377
  layers = webMapItem.tree.getDescendants();
7370
- promises_1 = [];
7371
- layers.forEach(function (x) {
7378
+ promises = [];
7379
+ _loop_2 = function (x) {
7372
7380
  var item = x.item;
7373
7381
  if (item.item_type === 'layer') {
7374
7382
  var id = item.layer_style_id;
7375
- var promise = _this.options.connector.getResource(id).then(function (y) {
7383
+ var promise = this_2.options.connector.getResource(id).then(function (y) {
7376
7384
  if (y) {
7377
7385
  var parentId = Number(y.resource.parent.id);
7378
7386
  item.parentId = parentId;
7379
7387
  return parentId;
7380
7388
  }
7381
7389
  });
7382
- promises_1.push(promise);
7390
+ promises.push(promise);
7383
7391
  }
7384
- });
7385
- return [4 /*yield*/, Promise.all(promises_1)];
7392
+ };
7393
+ this_2 = this;
7394
+ for (_i = 0, layers_1 = layers; _i < layers_1.length; _i++) {
7395
+ x = layers_1[_i];
7396
+ _loop_2(x);
7397
+ }
7398
+ return [4 /*yield*/, Promise.all(promises)];
7386
7399
  case 1:
7387
7400
  ids = _a.sent();
7388
7401
  return [2 /*return*/, ids.filter(function (x) { return x !== undefined; })];