@nextgis/ngw-map 1.13.5 → 1.13.8

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.13.5; author: NextGIS */
1
+ /** Bundle of @nextgis/ngw-map; version: 1.13.8; author: NextGIS */
2
2
  var NgwMap = (function (exports) {
3
3
  'use strict';
4
4
 
@@ -1506,16 +1506,17 @@ var NgwMap = (function (exports) {
1506
1506
  function createPropertiesPaint(propertiesPaint) {
1507
1507
  var mask = {};
1508
1508
  var paintsFilters = [];
1509
- propertiesPaint.forEach(function (x) {
1510
- if (x) {
1511
- if (Array.isArray(x)) {
1512
- paintsFilters.push(x);
1509
+ for (var _i = 0, propertiesPaint_1 = propertiesPaint; _i < propertiesPaint_1.length; _i++) {
1510
+ var p = propertiesPaint_1[_i];
1511
+ if (p) {
1512
+ if (Array.isArray(p)) {
1513
+ paintsFilters.push(p);
1513
1514
  }
1514
1515
  else {
1515
- mask = x;
1516
+ mask = p;
1516
1517
  }
1517
1518
  }
1518
- });
1519
+ }
1519
1520
  return function (feature) {
1520
1521
  var paint = paintsFilters.find(function (x) { return featureFilter(feature, x[0]); });
1521
1522
  if (paint) {
@@ -1555,9 +1556,11 @@ var NgwMap = (function (exports) {
1555
1556
  else {
1556
1557
  var expressionCallback_1 = createExpressionCallback(paint);
1557
1558
  if (expressionCallback_1) {
1558
- return function (feature) {
1559
+ var expressionPaintCb = function (feature) {
1559
1560
  return preparePaint(expressionCallback_1(feature), defaultPaint, getPaintFunctions);
1560
1561
  };
1562
+ expressionPaintCb.paint = paint;
1563
+ return expressionPaintCb;
1561
1564
  }
1562
1565
  newPaint = __assign(__assign({}, newPaint), paint);
1563
1566
  newPaint.fill = newPaint.fill !== undefined ? newPaint.fill : true;
@@ -2828,6 +2831,7 @@ var NgwMap = (function (exports) {
2828
2831
  };
2829
2832
  /** Shortcut for {@link WebMapLayers.addLayer} to create TileLayer adapter */
2830
2833
  WebMapLayers.prototype.addTileLayer = function (url, options) {
2834
+ if (options === void 0) { options = {}; }
2831
2835
  return this.addLayer('TILE', __assign(__assign({}, options), { url: url }));
2832
2836
  };
2833
2837
  WebMapLayers.prototype.addImageLayer = function (urlOrOptions, options) {
@@ -5071,51 +5075,6 @@ var NgwMap = (function (exports) {
5071
5075
  // export { NgwConnector };
5072
5076
  var NgwConnector = NgwConnector$1;
5073
5077
 
5074
- function createPopupContent(feature, item) {
5075
- // @ts-ignore
5076
- {
5077
- var element_1 = document.createElement('div');
5078
- if (item && item.feature_layer) {
5079
- item.feature_layer.fields.forEach(function (x) {
5080
- if (x.grid_visibility) {
5081
- var value = feature.properties && feature.properties[x.keyname];
5082
- if (value) {
5083
- var propElem = document.createElement('div');
5084
- element_1.appendChild(propElem);
5085
- propElem.innerHTML = "<span>".concat(x.display_name, "</span>: ").concat(value, "<span></span>");
5086
- }
5087
- }
5088
- });
5089
- }
5090
- else if (feature.properties) {
5091
- for (var p in feature.properties) {
5092
- var propElem = document.createElement('div');
5093
- element_1.appendChild(propElem);
5094
- propElem.innerHTML = "<span>".concat(p, "</span>: ").concat(feature.properties[p], "<span></span>");
5095
- }
5096
- }
5097
- return element_1;
5098
- }
5099
- }
5100
-
5101
- var filterOptionsKeys = [
5102
- 'fields',
5103
- 'intersects',
5104
- 'limit',
5105
- 'orderBy',
5106
- 'strategy',
5107
- ];
5108
- function getLayerFilterOptions(options) {
5109
- var filterOptions = {};
5110
- filterOptionsKeys.forEach(function (x) {
5111
- var opt = options[x];
5112
- if (opt !== undefined) {
5113
- filterOptions[x] = opt;
5114
- }
5115
- });
5116
- return filterOptions;
5117
- }
5118
-
5119
5078
  function getNgwWebmapExtent(webmap) {
5120
5079
  var bottom = webmap['extent_bottom'];
5121
5080
  var left = webmap['extent_left'];
@@ -5183,6 +5142,85 @@ var NgwMap = (function (exports) {
5183
5142
  }
5184
5143
  }
5185
5144
 
5145
+ var NgwResource = /** @class */ (function () {
5146
+ function NgwResource() {
5147
+ }
5148
+ /** @deprecated use {@link NgwResource.getBounds} instead */
5149
+ NgwResource.prototype.getExtent = function () {
5150
+ return __awaiter(this, void 0, void 0, function () {
5151
+ return __generator(this, function (_a) {
5152
+ return [2 /*return*/, this.getBounds()];
5153
+ });
5154
+ });
5155
+ };
5156
+ NgwResource.prototype.getBounds = function (options) {
5157
+ return __awaiter(this, void 0, void 0, function () {
5158
+ var _a;
5159
+ return __generator(this, function (_b) {
5160
+ switch (_b.label) {
5161
+ case 0:
5162
+ if (this._extent) {
5163
+ return [2 /*return*/, this._extent];
5164
+ }
5165
+ if (!this.item) return [3 /*break*/, 2];
5166
+ _a = this;
5167
+ return [4 /*yield*/, fetchNgwResourceExtent(this.item, this.connector, options)];
5168
+ case 1:
5169
+ _a._extent = _b.sent();
5170
+ return [2 /*return*/, this._extent];
5171
+ case 2: return [2 /*return*/];
5172
+ }
5173
+ });
5174
+ });
5175
+ };
5176
+ return NgwResource;
5177
+ }());
5178
+
5179
+ function createPopupContent(feature, item) {
5180
+ // @ts-ignore
5181
+ {
5182
+ var element_1 = document.createElement('div');
5183
+ if (item && item.feature_layer) {
5184
+ item.feature_layer.fields.forEach(function (x) {
5185
+ if (x.grid_visibility) {
5186
+ var value = feature.properties && feature.properties[x.keyname];
5187
+ if (value) {
5188
+ var propElem = document.createElement('div');
5189
+ element_1.appendChild(propElem);
5190
+ propElem.innerHTML = "<span>".concat(x.display_name, "</span>: ").concat(value, "<span></span>");
5191
+ }
5192
+ }
5193
+ });
5194
+ }
5195
+ else if (feature.properties) {
5196
+ for (var p in feature.properties) {
5197
+ var propElem = document.createElement('div');
5198
+ element_1.appendChild(propElem);
5199
+ propElem.innerHTML = "<span>".concat(p, "</span>: ").concat(feature.properties[p], "<span></span>");
5200
+ }
5201
+ }
5202
+ return element_1;
5203
+ }
5204
+ }
5205
+
5206
+ var filterOptionsKeys = [
5207
+ 'fields',
5208
+ 'intersects',
5209
+ 'limit',
5210
+ 'orderBy',
5211
+ 'strategy',
5212
+ ];
5213
+ function getLayerFilterOptions(options) {
5214
+ var filterOptions = {};
5215
+ filterOptionsKeys.forEach(function (x) {
5216
+ var opt = options[x];
5217
+ if (opt !== undefined) {
5218
+ filterOptions[x] = opt;
5219
+ }
5220
+ });
5221
+ return filterOptions;
5222
+ }
5223
+
5186
5224
  function resourceIdFromLayerOptions(options, connector) {
5187
5225
  return __awaiter(this, void 0, void 0, function () {
5188
5226
  var resource, item, keyname, resourceId, resourceItem;
@@ -5820,6 +5858,7 @@ var NgwMap = (function (exports) {
5820
5858
  };
5821
5859
  }
5822
5860
  function ngwApiToAdapterOptions(_a) {
5861
+ var _b;
5823
5862
  var options = _a.options, webMap = _a.webMap, baseUrl = _a.baseUrl;
5824
5863
  var adapter = options.adapter || 'IMAGE';
5825
5864
  var url;
@@ -5859,10 +5898,12 @@ var NgwMap = (function (exports) {
5859
5898
  'resource=' +
5860
5899
  resourceId +
5861
5900
  '&simplification=' +
5862
- (options.simplification || 0);
5901
+ ((_b = options.simplification) !== null && _b !== void 0 ? _b : 8);
5863
5902
  // url = baseUrl + '/api/resource/' + options.resourceId + '/{z}/{x}/{y}.mvt';
5864
5903
  return {
5865
5904
  url: url,
5905
+ sourceLayer: 'ngw:' + resourceId,
5906
+ featureIdName: '$id',
5866
5907
  };
5867
5908
  }
5868
5909
  if (adapter === 'TERRAIN') {
@@ -5925,7 +5966,6 @@ var NgwMap = (function (exports) {
5925
5966
  return [2 /*return*/, /** @class */ (function (_super) {
5926
5967
  __extends(RasterAdapter, _super);
5927
5968
  function RasterAdapter(map, _options) {
5928
- var _a;
5929
5969
  var _this = _super.call(this, map, _options) || this;
5930
5970
  _this.map = map;
5931
5971
  // options = {};
@@ -5937,7 +5977,7 @@ var NgwMap = (function (exports) {
5937
5977
  baseUrl: connector.options.baseUrl || '',
5938
5978
  });
5939
5979
  if (opt) {
5940
- var layerAdapterOptions = __assign(__assign({}, opt), { setViewDelay: (_a = layerOptions.adapterOptions) === null || _a === void 0 ? void 0 : _a.setViewDelay, params: { resource: resourceId_1 },
5980
+ var layerAdapterOptions = __assign(__assign(__assign({}, opt), layerOptions.adapterOptions), { params: { resource: resourceId_1 },
5941
5981
  // @deprecated
5942
5982
  layers: String(resourceId_1), resourceId: resourceId_1 });
5943
5983
  if (layerOptions.adapterOptions &&
@@ -5970,11 +6010,16 @@ var NgwMap = (function (exports) {
5970
6010
  return __awaiter(this, void 0, void 0, function () {
5971
6011
  var id;
5972
6012
  return __generator(this, function (_a) {
5973
- id = this.item && this.item.resource.parent.id;
5974
- if (defined(id)) {
5975
- return [2 /*return*/, [id]];
6013
+ if (this.item) {
6014
+ if (adapter === 'MVT') {
6015
+ return [2 /*return*/, [this.item.resource.id]];
6016
+ }
6017
+ id = this.item.resource.parent.id;
6018
+ if (defined(id)) {
6019
+ return [2 /*return*/, [id]];
6020
+ }
5976
6021
  }
5977
- return [2 /*return*/];
6022
+ return [2 /*return*/, []];
5978
6023
  });
5979
6024
  });
5980
6025
  };
@@ -7380,40 +7425,6 @@ var NgwMap = (function (exports) {
7380
7425
  });
7381
7426
  }
7382
7427
 
7383
- var NgwResource = /** @class */ (function () {
7384
- function NgwResource() {
7385
- }
7386
- /** @deprecated use {@link NgwResource.getBounds} instead */
7387
- NgwResource.prototype.getExtent = function () {
7388
- return __awaiter(this, void 0, void 0, function () {
7389
- return __generator(this, function (_a) {
7390
- return [2 /*return*/, this.getBounds()];
7391
- });
7392
- });
7393
- };
7394
- NgwResource.prototype.getBounds = function (options) {
7395
- return __awaiter(this, void 0, void 0, function () {
7396
- var _a;
7397
- return __generator(this, function (_b) {
7398
- switch (_b.label) {
7399
- case 0:
7400
- if (this._extent) {
7401
- return [2 /*return*/, this._extent];
7402
- }
7403
- if (!this.item) return [3 /*break*/, 2];
7404
- _a = this;
7405
- return [4 /*yield*/, fetchNgwResourceExtent(this.item, this.connector, options)];
7406
- case 1:
7407
- _a._extent = _b.sent();
7408
- return [2 /*return*/, this._extent];
7409
- case 2: return [2 /*return*/];
7410
- }
7411
- });
7412
- });
7413
- };
7414
- return NgwResource;
7415
- }());
7416
-
7417
7428
  var alias = {
7418
7429
  tms: 'TILE',
7419
7430
  };
@@ -7641,7 +7652,7 @@ var NgwMap = (function (exports) {
7641
7652
  }
7642
7653
  function createAsyncAdapter(options, webMap, connector) {
7643
7654
  return __awaiter(this, void 0, void 0, function () {
7644
- var adapter, item, adapterType, resourceId, resourceOptions, itemFromResOpt, cls, layerOptions, adapterOptions, parentItem, parentOptions, getClassAdapter, classAdapter;
7655
+ var adapter, item, adapterType, resourceId, resourceOptions, itemFromResOpt, cls, layerOptions, adapterOptions, type, adapterOptions_, parentItem, parentOptions, getClassAdapter, classAdapter;
7645
7656
  return __generator(this, function (_a) {
7646
7657
  switch (_a.label) {
7647
7658
  case 0:
@@ -7677,6 +7688,12 @@ var NgwMap = (function (exports) {
7677
7688
  return [3 /*break*/, 11];
7678
7689
  case 5:
7679
7690
  if (!(cls === 'vector_layer')) return [3 /*break*/, 6];
7691
+ type = item.vector_layer &&
7692
+ vectorLayerGeomToPaintTypeAlias[item.vector_layer.geometry_type];
7693
+ adapterOptions_ = adapterOptions.layerOptions.adapterOptions || {};
7694
+ adapterOptions_.type = adapterOptions_.type || type;
7695
+ adapterOptions.layerOptions.adapterOptions = adapterOptions_;
7696
+ options.adapterOptions = adapterOptions;
7680
7697
  if (adapterType !== undefined && adapterType !== 'GEOJSON') {
7681
7698
  if (adapterType === 'MVT') {
7682
7699
  adapter = createRasterAdapter(adapterOptions);
@@ -8857,7 +8874,7 @@ var NgwMap = (function (exports) {
8857
8874
  };
8858
8875
  NgwMap.prototype._selectFromNgwRaster = function (ev) {
8859
8876
  return __awaiter(this, void 0, void 0, function () {
8860
- var promises, layers, getIdsPromise, getIds, ids, pixelRadius, center, zoom, radius, selectPromise;
8877
+ var promises, layers, _i, layers_1, l, layer, identFunc, getIdsPromise, getIds, ids, pixelRadius, center, zoom, radius, selectPromise;
8861
8878
  var _this = this;
8862
8879
  return __generator(this, function (_a) {
8863
8880
  switch (_a.label) {
@@ -8871,15 +8888,16 @@ var NgwMap = (function (exports) {
8871
8888
  }
8872
8889
  return 1;
8873
8890
  });
8874
- layers.forEach(function (l) {
8875
- var layer = l.layer;
8876
- var identFunc = typeof layer.getIdentificationIds === 'function'
8891
+ for (_i = 0, layers_1 = layers; _i < layers_1.length; _i++) {
8892
+ l = layers_1[_i];
8893
+ layer = l.layer;
8894
+ identFunc = typeof layer.getIdentificationIds === 'function'
8877
8895
  ? layer.getIdentificationIds
8878
8896
  : false;
8879
- if (identFunc && layer.options.selectable && _this.isLayerVisible(layer)) {
8897
+ if (identFunc && layer.options.selectable && this.isLayerVisible(layer)) {
8880
8898
  promises.push(identFunc.call(layer));
8881
8899
  }
8882
- });
8900
+ }
8883
8901
  getIdsPromise = Promise.all(promises);
8884
8902
  return [4 /*yield*/, getIdsPromise];
8885
8903
  case 1: