@nextgis/ngw-map 1.13.7 → 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.7; 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;
@@ -5072,51 +5075,6 @@ var NgwMap = (function (exports) {
5072
5075
  // export { NgwConnector };
5073
5076
  var NgwConnector = NgwConnector$1;
5074
5077
 
5075
- function createPopupContent(feature, item) {
5076
- // @ts-ignore
5077
- {
5078
- var element_1 = document.createElement('div');
5079
- if (item && item.feature_layer) {
5080
- item.feature_layer.fields.forEach(function (x) {
5081
- if (x.grid_visibility) {
5082
- var value = feature.properties && feature.properties[x.keyname];
5083
- if (value) {
5084
- var propElem = document.createElement('div');
5085
- element_1.appendChild(propElem);
5086
- propElem.innerHTML = "<span>".concat(x.display_name, "</span>: ").concat(value, "<span></span>");
5087
- }
5088
- }
5089
- });
5090
- }
5091
- else if (feature.properties) {
5092
- for (var p in feature.properties) {
5093
- var propElem = document.createElement('div');
5094
- element_1.appendChild(propElem);
5095
- propElem.innerHTML = "<span>".concat(p, "</span>: ").concat(feature.properties[p], "<span></span>");
5096
- }
5097
- }
5098
- return element_1;
5099
- }
5100
- }
5101
-
5102
- var filterOptionsKeys = [
5103
- 'fields',
5104
- 'intersects',
5105
- 'limit',
5106
- 'orderBy',
5107
- 'strategy',
5108
- ];
5109
- function getLayerFilterOptions(options) {
5110
- var filterOptions = {};
5111
- filterOptionsKeys.forEach(function (x) {
5112
- var opt = options[x];
5113
- if (opt !== undefined) {
5114
- filterOptions[x] = opt;
5115
- }
5116
- });
5117
- return filterOptions;
5118
- }
5119
-
5120
5078
  function getNgwWebmapExtent(webmap) {
5121
5079
  var bottom = webmap['extent_bottom'];
5122
5080
  var left = webmap['extent_left'];
@@ -5184,6 +5142,85 @@ var NgwMap = (function (exports) {
5184
5142
  }
5185
5143
  }
5186
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
+
5187
5224
  function resourceIdFromLayerOptions(options, connector) {
5188
5225
  return __awaiter(this, void 0, void 0, function () {
5189
5226
  var resource, item, keyname, resourceId, resourceItem;
@@ -5821,6 +5858,7 @@ var NgwMap = (function (exports) {
5821
5858
  };
5822
5859
  }
5823
5860
  function ngwApiToAdapterOptions(_a) {
5861
+ var _b;
5824
5862
  var options = _a.options, webMap = _a.webMap, baseUrl = _a.baseUrl;
5825
5863
  var adapter = options.adapter || 'IMAGE';
5826
5864
  var url;
@@ -5860,7 +5898,7 @@ var NgwMap = (function (exports) {
5860
5898
  'resource=' +
5861
5899
  resourceId +
5862
5900
  '&simplification=' +
5863
- (options.simplification || 0);
5901
+ ((_b = options.simplification) !== null && _b !== void 0 ? _b : 8);
5864
5902
  // url = baseUrl + '/api/resource/' + options.resourceId + '/{z}/{x}/{y}.mvt';
5865
5903
  return {
5866
5904
  url: url,
@@ -5928,7 +5966,6 @@ var NgwMap = (function (exports) {
5928
5966
  return [2 /*return*/, /** @class */ (function (_super) {
5929
5967
  __extends(RasterAdapter, _super);
5930
5968
  function RasterAdapter(map, _options) {
5931
- var _a;
5932
5969
  var _this = _super.call(this, map, _options) || this;
5933
5970
  _this.map = map;
5934
5971
  // options = {};
@@ -5940,7 +5977,7 @@ var NgwMap = (function (exports) {
5940
5977
  baseUrl: connector.options.baseUrl || '',
5941
5978
  });
5942
5979
  if (opt) {
5943
- 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 },
5944
5981
  // @deprecated
5945
5982
  layers: String(resourceId_1), resourceId: resourceId_1 });
5946
5983
  if (layerOptions.adapterOptions &&
@@ -5973,11 +6010,16 @@ var NgwMap = (function (exports) {
5973
6010
  return __awaiter(this, void 0, void 0, function () {
5974
6011
  var id;
5975
6012
  return __generator(this, function (_a) {
5976
- id = this.item && this.item.resource.parent.id;
5977
- if (defined(id)) {
5978
- 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
+ }
5979
6021
  }
5980
- return [2 /*return*/];
6022
+ return [2 /*return*/, []];
5981
6023
  });
5982
6024
  });
5983
6025
  };
@@ -7383,40 +7425,6 @@ var NgwMap = (function (exports) {
7383
7425
  });
7384
7426
  }
7385
7427
 
7386
- var NgwResource = /** @class */ (function () {
7387
- function NgwResource() {
7388
- }
7389
- /** @deprecated use {@link NgwResource.getBounds} instead */
7390
- NgwResource.prototype.getExtent = function () {
7391
- return __awaiter(this, void 0, void 0, function () {
7392
- return __generator(this, function (_a) {
7393
- return [2 /*return*/, this.getBounds()];
7394
- });
7395
- });
7396
- };
7397
- NgwResource.prototype.getBounds = function (options) {
7398
- return __awaiter(this, void 0, void 0, function () {
7399
- var _a;
7400
- return __generator(this, function (_b) {
7401
- switch (_b.label) {
7402
- case 0:
7403
- if (this._extent) {
7404
- return [2 /*return*/, this._extent];
7405
- }
7406
- if (!this.item) return [3 /*break*/, 2];
7407
- _a = this;
7408
- return [4 /*yield*/, fetchNgwResourceExtent(this.item, this.connector, options)];
7409
- case 1:
7410
- _a._extent = _b.sent();
7411
- return [2 /*return*/, this._extent];
7412
- case 2: return [2 /*return*/];
7413
- }
7414
- });
7415
- });
7416
- };
7417
- return NgwResource;
7418
- }());
7419
-
7420
7428
  var alias = {
7421
7429
  tms: 'TILE',
7422
7430
  };
@@ -7644,7 +7652,7 @@ var NgwMap = (function (exports) {
7644
7652
  }
7645
7653
  function createAsyncAdapter(options, webMap, connector) {
7646
7654
  return __awaiter(this, void 0, void 0, function () {
7647
- 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;
7648
7656
  return __generator(this, function (_a) {
7649
7657
  switch (_a.label) {
7650
7658
  case 0:
@@ -7680,6 +7688,12 @@ var NgwMap = (function (exports) {
7680
7688
  return [3 /*break*/, 11];
7681
7689
  case 5:
7682
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;
7683
7697
  if (adapterType !== undefined && adapterType !== 'GEOJSON') {
7684
7698
  if (adapterType === 'MVT') {
7685
7699
  adapter = createRasterAdapter(adapterOptions);
@@ -8860,7 +8874,7 @@ var NgwMap = (function (exports) {
8860
8874
  };
8861
8875
  NgwMap.prototype._selectFromNgwRaster = function (ev) {
8862
8876
  return __awaiter(this, void 0, void 0, function () {
8863
- 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;
8864
8878
  var _this = this;
8865
8879
  return __generator(this, function (_a) {
8866
8880
  switch (_a.label) {
@@ -8874,15 +8888,16 @@ var NgwMap = (function (exports) {
8874
8888
  }
8875
8889
  return 1;
8876
8890
  });
8877
- layers.forEach(function (l) {
8878
- var layer = l.layer;
8879
- 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'
8880
8895
  ? layer.getIdentificationIds
8881
8896
  : false;
8882
- if (identFunc && layer.options.selectable && _this.isLayerVisible(layer)) {
8897
+ if (identFunc && layer.options.selectable && this.isLayerVisible(layer)) {
8883
8898
  promises.push(identFunc.call(layer));
8884
8899
  }
8885
- });
8900
+ }
8886
8901
  getIdsPromise = Promise.all(promises);
8887
8902
  return [4 /*yield*/, getIdsPromise];
8888
8903
  case 1: