@nextgis/ngw-leaflet 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-leaflet; version: 1.15.1; author: NextGIS */
1
+ /** Bundle of @nextgis/ngw-leaflet; version: 1.16.0; author: NextGIS */
2
2
  /******************************************************************************
3
3
  Copyright (c) Microsoft Corporation.
4
4
 
@@ -15613,6 +15613,24 @@ function createPropertiesPaint(propertiesPaint) {
15613
15613
  return mask;
15614
15614
  };
15615
15615
  }
15616
+ function expressionCallback(paint, defaultPaint, getPaintFunctions) {
15617
+ var expressionCallback = createExpressionCallback(paint);
15618
+ if (expressionCallback) {
15619
+ var expressionPaintCb = function (feature) {
15620
+ return preparePaint(expressionCallback(feature), defaultPaint, getPaintFunctions);
15621
+ };
15622
+ expressionPaintCb.paint = paint;
15623
+ return expressionPaintCb;
15624
+ }
15625
+ var newPaint = __assign({}, defaultPaint);
15626
+ newPaint = __assign(__assign({}, newPaint), paint);
15627
+ newPaint.fill = newPaint.fill !== undefined ? newPaint.fill : true;
15628
+ newPaint.stroke =
15629
+ newPaint.stroke !== undefined
15630
+ ? newPaint.stroke
15631
+ : !newPaint.fill || !!(newPaint.strokeColor || newPaint.strokeOpacity);
15632
+ return newPaint;
15633
+ }
15616
15634
  function preparePaint(paint, defaultPaint, getPaintFunctions) {
15617
15635
  if (!paint) {
15618
15636
  throw new Error('paint is empty');
@@ -15642,20 +15660,7 @@ function preparePaint(paint, defaultPaint, getPaintFunctions) {
15642
15660
  return paint;
15643
15661
  }
15644
15662
  else {
15645
- var expressionCallback_1 = createExpressionCallback(paint);
15646
- if (expressionCallback_1) {
15647
- var expressionPaintCb = function (feature) {
15648
- return preparePaint(expressionCallback_1(feature), defaultPaint, getPaintFunctions);
15649
- };
15650
- expressionPaintCb.paint = paint;
15651
- return expressionPaintCb;
15652
- }
15653
- newPaint = __assign(__assign({}, newPaint), paint);
15654
- newPaint.fill = newPaint.fill !== undefined ? newPaint.fill : true;
15655
- newPaint.stroke =
15656
- newPaint.stroke !== undefined
15657
- ? newPaint.stroke
15658
- : !newPaint.fill || !!(newPaint.strokeColor || newPaint.strokeOpacity);
15663
+ newPaint = expressionCallback(paint, defaultPaint, getPaintFunctions);
15659
15664
  }
15660
15665
  if (isPaintCallback(newPaint)) {
15661
15666
  return newPaint;
@@ -20703,10 +20708,12 @@ var NgwWebmapItem = /** @class */ (function (_super) {
20703
20708
  };
20704
20709
  if (item.item_type === 'group' || item.item_type === 'root') {
20705
20710
  if (item.children && item.children.length) {
20706
- this.getChildren(item).forEach(function (x) {
20707
- var children = new NgwWebmapItem(_this.webMap, x, _this.options, _this.connector, _this);
20708
- _this.tree.addChild(children);
20709
- });
20711
+ var children = this.getChildren(item);
20712
+ for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
20713
+ var x = children_1[_i];
20714
+ var children_2 = new this.constructor(this.webMap, x, this.options, this.connector, this);
20715
+ this.tree.addChild(children_2);
20716
+ }
20710
20717
  }
20711
20718
  return Promise.resolve();
20712
20719
  }
@@ -20747,7 +20754,7 @@ var NgwWebmapItem = /** @class */ (function (_super) {
20747
20754
  headers: this.options.headers,
20748
20755
  crossOrigin: this.options.crossOrigin,
20749
20756
  setViewDelay: this.options.setViewDelay,
20750
- params: { resource: this.item.resourceId },
20757
+ params: { resource: this.item.resourceId, item: this.item },
20751
20758
  };
20752
20759
  if (this.options.order) {
20753
20760
  var subOrder = this.options.drawOrderEnabled && 'draw_order_position' in item
@@ -20758,6 +20765,9 @@ var NgwWebmapItem = /** @class */ (function (_super) {
20758
20765
  var subLevel = String(subOrder).padStart(4, '0');
20759
20766
  options.order = Number((this.options.order | 0) + '.' + subLevel);
20760
20767
  }
20768
+ if (this.options.popupOptions) {
20769
+ options.popupOptions = this.options.popupOptions;
20770
+ }
20761
20771
  if (item.item_type === 'layer') {
20762
20772
  var _a = this._getZoomRange(item), maxZoom = _a.maxZoom, minZoom = _a.minZoom;
20763
20773
  objectAssign(options, {
@@ -20805,8 +20815,8 @@ var NgwWebmapItem = /** @class */ (function (_super) {
20805
20815
  };
20806
20816
  NgwWebmapItem.prototype._sumUp = function (children, totalValue) {
20807
20817
  if (totalValue === void 0) { totalValue = 0; }
20808
- for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
20809
- var child = children_1[_i];
20818
+ for (var _i = 0, children_3 = children; _i < children_3.length; _i++) {
20819
+ var child = children_3[_i];
20810
20820
  if (child.item_type === 'layer') {
20811
20821
  totalValue += 1;
20812
20822
  child.draw_order_position = child.draw_order_position || totalValue;
@@ -21113,8 +21123,6 @@ var NgwWebmapLayerAdapter = /** @class */ (function () {
21113
21123
  this._extent &&
21114
21124
  extentConstrained) {
21115
21125
  this.options.webMap.setView({ maxBounds: this._extent });
21116
- // @ts-ignore
21117
- window.webmap = this.options.webMap;
21118
21126
  }
21119
21127
  return [2 /*return*/, this.layer];
21120
21128
  }
@@ -21287,6 +21295,7 @@ var NgwWebmapLayerAdapter = /** @class */ (function () {
21287
21295
  options.minZoom = _this.options.minZoom;
21288
21296
  options.maxZoom = _this.options.maxZoom;
21289
21297
  options.drawOrderEnabled = webmap_1.draw_order_enabled;
21298
+ options.popupOptions = _this.options.popupOptions;
21290
21299
  var layer = new _this.NgwWebmapItem(_this.options.webMap, webmap_1.root_item, options, _this.options.connector);
21291
21300
  layer.emitter.on('init', function () { return resolve(layer); });
21292
21301
  })];
@@ -21417,30 +21426,34 @@ var NgwWebmapLayerAdapter = /** @class */ (function () {
21417
21426
  };
21418
21427
  NgwWebmapLayerAdapter.prototype._getWebMapIds = function () {
21419
21428
  return __awaiter(this, void 0, void 0, function () {
21420
- var webMapItem, layers, promises_1, ids;
21421
- var _this = this;
21429
+ var webMapItem, layers, promises, _loop_2, this_2, _i, layers_1, x, ids;
21422
21430
  return __generator(this, function (_a) {
21423
21431
  switch (_a.label) {
21424
21432
  case 0:
21425
21433
  webMapItem = this.layer;
21426
21434
  if (!(webMapItem && webMapItem.item.item_type === 'root')) return [3 /*break*/, 2];
21427
21435
  layers = webMapItem.tree.getDescendants();
21428
- promises_1 = [];
21429
- layers.forEach(function (x) {
21436
+ promises = [];
21437
+ _loop_2 = function (x) {
21430
21438
  var item = x.item;
21431
21439
  if (item.item_type === 'layer') {
21432
21440
  var id = item.layer_style_id;
21433
- var promise = _this.options.connector.getResource(id).then(function (y) {
21441
+ var promise = this_2.options.connector.getResource(id).then(function (y) {
21434
21442
  if (y) {
21435
21443
  var parentId = Number(y.resource.parent.id);
21436
21444
  item.parentId = parentId;
21437
21445
  return parentId;
21438
21446
  }
21439
21447
  });
21440
- promises_1.push(promise);
21448
+ promises.push(promise);
21441
21449
  }
21442
- });
21443
- return [4 /*yield*/, Promise.all(promises_1)];
21450
+ };
21451
+ this_2 = this;
21452
+ for (_i = 0, layers_1 = layers; _i < layers_1.length; _i++) {
21453
+ x = layers_1[_i];
21454
+ _loop_2(x);
21455
+ }
21456
+ return [4 /*yield*/, Promise.all(promises)];
21444
21457
  case 1:
21445
21458
  ids = _a.sent();
21446
21459
  return [2 /*return*/, ids.filter(function (x) { return x !== undefined; })];
@@ -23306,12 +23319,13 @@ var GeoJsonAdapter = /** @class */ (function (_super) {
23306
23319
  this._removeMapListener();
23307
23320
  };
23308
23321
  GeoJsonAdapter.prototype.select = function (findFeatureFun) {
23309
- var _this = this;
23322
+ this.unselect();
23310
23323
  if (findFeatureFun) {
23311
23324
  var def = this._layers.filter(findFeatureFun);
23312
- def.forEach(function (x) {
23313
- _this._selectLayer(x, 'api');
23314
- });
23325
+ for (var _i = 0, def_1 = def; _i < def_1.length; _i++) {
23326
+ var x = def_1[_i];
23327
+ this._selectLayer(x, 'api');
23328
+ }
23315
23329
  }
23316
23330
  else if (!this.selected) {
23317
23331
  this.selected = true;
@@ -23724,13 +23738,13 @@ var GeoJsonAdapter = /** @class */ (function (_super) {
23724
23738
  var _this = this;
23725
23739
  var layer_ = this.layer;
23726
23740
  if (layer_) {
23727
- var def_1 = __assign({ target: this, feature: feature, layer: layer }, createFeaturePositionOptions(feature));
23741
+ var def_2 = __assign({ target: this, feature: feature, layer: layer }, createFeaturePositionOptions(feature));
23728
23742
  // @ts-ignore
23729
23743
  layer.options.pane = this.pane;
23730
- this._layers.push(def_1);
23744
+ this._layers.push(def_2);
23731
23745
  var ok = true;
23732
23746
  if (this._filterFun) {
23733
- ok = this._filterFun(def_1);
23747
+ ok = this._filterFun(def_2);
23734
23748
  }
23735
23749
  if (ok) {
23736
23750
  var _a = this.options, popup_1 = _a.popup, popupOptions_1 = _a.popupOptions, selectable = _a.selectable, interactive = _a.interactive, selectOnHover = _a.selectOnHover;
@@ -23740,10 +23754,10 @@ var GeoJsonAdapter = /** @class */ (function (_super) {
23740
23754
  if (selectable) {
23741
23755
  if (selectOnHover) {
23742
23756
  layer.on('mouseover', function () {
23743
- _this._selectLayer(def_1, 'hover');
23757
+ _this._selectLayer(def_2, 'hover');
23744
23758
  });
23745
23759
  layer.on('mouseout', function () {
23746
- _this._unSelectLayer(def_1);
23760
+ _this._unSelectLayer(def_2);
23747
23761
  });
23748
23762
  }
23749
23763
  else {
@@ -23810,10 +23824,12 @@ var GeoJsonAdapter = /** @class */ (function (_super) {
23810
23824
  };
23811
23825
  GeoJsonAdapter.prototype._selectLayer = function (def, type, latlng) {
23812
23826
  var _this = this;
23813
- this.map._addUnselectCb(function () {
23814
- _this._unSelectLayer(def);
23815
- });
23816
- if (this.options && !this.options.multiselect) {
23827
+ var multiselect = this.options.multiselect;
23828
+ if (!multiselect) {
23829
+ // To unselect layer on another layer click
23830
+ this.map._addUnselectCb(function () {
23831
+ _this._unSelectLayer(def);
23832
+ });
23817
23833
  this._selectedLayers.forEach(function (x) { return _this._unSelectLayer(x); });
23818
23834
  }
23819
23835
  this._selectedLayers.push(def);
@@ -23890,14 +23906,26 @@ var GeoJsonAdapter = /** @class */ (function (_super) {
23890
23906
  }
23891
23907
  return geoJsonOptions;
23892
23908
  };
23893
- GeoJsonAdapter.prototype._addMapListener = function () {
23909
+ GeoJsonAdapter.prototype._addMapClickListener = function () {
23894
23910
  var map = this.map;
23895
23911
  if (map) {
23896
- var _a = this.options, labelField = _a.labelField, labelOnHover = _a.labelOnHover, unselectOnClick = _a.unselectOnClick;
23912
+ var unselectOnClick = this.options.unselectOnClick;
23897
23913
  var uoc = unselectOnClick !== null && unselectOnClick !== void 0 ? unselectOnClick : true;
23898
23914
  if (uoc) {
23899
23915
  map.on('click', this.$unselect);
23900
23916
  }
23917
+ }
23918
+ };
23919
+ GeoJsonAdapter.prototype._removeMapClickListener = function () {
23920
+ this.map.off('zoomend', this.$updateTooltip);
23921
+ this.map.off('moveend', this.$updateTooltip);
23922
+ this.map.off('click', this.$unselect);
23923
+ };
23924
+ GeoJsonAdapter.prototype._addMapListener = function () {
23925
+ var map = this.map;
23926
+ if (map) {
23927
+ var _a = this.options, labelField = _a.labelField, labelOnHover = _a.labelOnHover;
23928
+ this._addMapClickListener();
23901
23929
  if (labelField && !labelOnHover) {
23902
23930
  map.on('zoomend', this.$updateTooltip);
23903
23931
  map.on('moveend', this.$updateTooltip);
@@ -23905,9 +23933,9 @@ var GeoJsonAdapter = /** @class */ (function (_super) {
23905
23933
  }
23906
23934
  };
23907
23935
  GeoJsonAdapter.prototype._removeMapListener = function () {
23936
+ this._removeMapClickListener();
23908
23937
  this.map.off('zoomend', this.$updateTooltip);
23909
23938
  this.map.off('moveend', this.$updateTooltip);
23910
- this.map.off('click', this.$unselect);
23911
23939
  };
23912
23940
  return GeoJsonAdapter;
23913
23941
  }(BaseAdapter));