@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
  /*! *****************************************************************************
3
3
  Copyright (c) Microsoft Corporation.
4
4
 
@@ -1503,16 +1503,17 @@ function updatePaintOptionFromCallback(paint, getPaintFunctions) {
1503
1503
  function createPropertiesPaint(propertiesPaint) {
1504
1504
  var mask = {};
1505
1505
  var paintsFilters = [];
1506
- propertiesPaint.forEach(function (x) {
1507
- if (x) {
1508
- if (Array.isArray(x)) {
1509
- paintsFilters.push(x);
1506
+ for (var _i = 0, propertiesPaint_1 = propertiesPaint; _i < propertiesPaint_1.length; _i++) {
1507
+ var p = propertiesPaint_1[_i];
1508
+ if (p) {
1509
+ if (Array.isArray(p)) {
1510
+ paintsFilters.push(p);
1510
1511
  }
1511
1512
  else {
1512
- mask = x;
1513
+ mask = p;
1513
1514
  }
1514
1515
  }
1515
- });
1516
+ }
1516
1517
  return function (feature) {
1517
1518
  var paint = paintsFilters.find(function (x) { return featureFilter(feature, x[0]); });
1518
1519
  if (paint) {
@@ -1552,9 +1553,11 @@ function preparePaint(paint, defaultPaint, getPaintFunctions) {
1552
1553
  else {
1553
1554
  var expressionCallback_1 = createExpressionCallback(paint);
1554
1555
  if (expressionCallback_1) {
1555
- return function (feature) {
1556
+ var expressionPaintCb = function (feature) {
1556
1557
  return preparePaint(expressionCallback_1(feature), defaultPaint, getPaintFunctions);
1557
1558
  };
1559
+ expressionPaintCb.paint = paint;
1560
+ return expressionPaintCb;
1558
1561
  }
1559
1562
  newPaint = __assign(__assign({}, newPaint), paint);
1560
1563
  newPaint.fill = newPaint.fill !== undefined ? newPaint.fill : true;
@@ -5069,51 +5072,6 @@ var NgwConnector$1 = /** @class */ (function () {
5069
5072
  // export { NgwConnector };
5070
5073
  var NgwConnector = NgwConnector$1;
5071
5074
 
5072
- function createPopupContent(feature, item) {
5073
- // @ts-ignore
5074
- {
5075
- var element_1 = document.createElement('div');
5076
- if (item && item.feature_layer) {
5077
- item.feature_layer.fields.forEach(function (x) {
5078
- if (x.grid_visibility) {
5079
- var value = feature.properties && feature.properties[x.keyname];
5080
- if (value) {
5081
- var propElem = document.createElement('div');
5082
- element_1.appendChild(propElem);
5083
- propElem.innerHTML = "<span>".concat(x.display_name, "</span>: ").concat(value, "<span></span>");
5084
- }
5085
- }
5086
- });
5087
- }
5088
- else if (feature.properties) {
5089
- for (var p in feature.properties) {
5090
- var propElem = document.createElement('div');
5091
- element_1.appendChild(propElem);
5092
- propElem.innerHTML = "<span>".concat(p, "</span>: ").concat(feature.properties[p], "<span></span>");
5093
- }
5094
- }
5095
- return element_1;
5096
- }
5097
- }
5098
-
5099
- var filterOptionsKeys = [
5100
- 'fields',
5101
- 'intersects',
5102
- 'limit',
5103
- 'orderBy',
5104
- 'strategy',
5105
- ];
5106
- function getLayerFilterOptions(options) {
5107
- var filterOptions = {};
5108
- filterOptionsKeys.forEach(function (x) {
5109
- var opt = options[x];
5110
- if (opt !== undefined) {
5111
- filterOptions[x] = opt;
5112
- }
5113
- });
5114
- return filterOptions;
5115
- }
5116
-
5117
5075
  function getNgwWebmapExtent(webmap) {
5118
5076
  var bottom = webmap['extent_bottom'];
5119
5077
  var left = webmap['extent_left'];
@@ -5181,6 +5139,85 @@ function fetchNgwResourceExtent(item, connector, options) {
5181
5139
  }
5182
5140
  }
5183
5141
 
5142
+ var NgwResource = /** @class */ (function () {
5143
+ function NgwResource() {
5144
+ }
5145
+ /** @deprecated use {@link NgwResource.getBounds} instead */
5146
+ NgwResource.prototype.getExtent = function () {
5147
+ return __awaiter(this, void 0, void 0, function () {
5148
+ return __generator(this, function (_a) {
5149
+ return [2 /*return*/, this.getBounds()];
5150
+ });
5151
+ });
5152
+ };
5153
+ NgwResource.prototype.getBounds = function (options) {
5154
+ return __awaiter(this, void 0, void 0, function () {
5155
+ var _a;
5156
+ return __generator(this, function (_b) {
5157
+ switch (_b.label) {
5158
+ case 0:
5159
+ if (this._extent) {
5160
+ return [2 /*return*/, this._extent];
5161
+ }
5162
+ if (!this.item) return [3 /*break*/, 2];
5163
+ _a = this;
5164
+ return [4 /*yield*/, fetchNgwResourceExtent(this.item, this.connector, options)];
5165
+ case 1:
5166
+ _a._extent = _b.sent();
5167
+ return [2 /*return*/, this._extent];
5168
+ case 2: return [2 /*return*/];
5169
+ }
5170
+ });
5171
+ });
5172
+ };
5173
+ return NgwResource;
5174
+ }());
5175
+
5176
+ function createPopupContent(feature, item) {
5177
+ // @ts-ignore
5178
+ {
5179
+ var element_1 = document.createElement('div');
5180
+ if (item && item.feature_layer) {
5181
+ item.feature_layer.fields.forEach(function (x) {
5182
+ if (x.grid_visibility) {
5183
+ var value = feature.properties && feature.properties[x.keyname];
5184
+ if (value) {
5185
+ var propElem = document.createElement('div');
5186
+ element_1.appendChild(propElem);
5187
+ propElem.innerHTML = "<span>".concat(x.display_name, "</span>: ").concat(value, "<span></span>");
5188
+ }
5189
+ }
5190
+ });
5191
+ }
5192
+ else if (feature.properties) {
5193
+ for (var p in feature.properties) {
5194
+ var propElem = document.createElement('div');
5195
+ element_1.appendChild(propElem);
5196
+ propElem.innerHTML = "<span>".concat(p, "</span>: ").concat(feature.properties[p], "<span></span>");
5197
+ }
5198
+ }
5199
+ return element_1;
5200
+ }
5201
+ }
5202
+
5203
+ var filterOptionsKeys = [
5204
+ 'fields',
5205
+ 'intersects',
5206
+ 'limit',
5207
+ 'orderBy',
5208
+ 'strategy',
5209
+ ];
5210
+ function getLayerFilterOptions(options) {
5211
+ var filterOptions = {};
5212
+ filterOptionsKeys.forEach(function (x) {
5213
+ var opt = options[x];
5214
+ if (opt !== undefined) {
5215
+ filterOptions[x] = opt;
5216
+ }
5217
+ });
5218
+ return filterOptions;
5219
+ }
5220
+
5184
5221
  function resourceIdFromLayerOptions(options, connector) {
5185
5222
  return __awaiter(this, void 0, void 0, function () {
5186
5223
  var resource, item, keyname, resourceId, resourceItem;
@@ -5818,6 +5855,7 @@ function getImageAdapterOptions(_a) {
5818
5855
  };
5819
5856
  }
5820
5857
  function ngwApiToAdapterOptions(_a) {
5858
+ var _b;
5821
5859
  var options = _a.options, webMap = _a.webMap, baseUrl = _a.baseUrl;
5822
5860
  var adapter = options.adapter || 'IMAGE';
5823
5861
  var url;
@@ -5857,7 +5895,7 @@ function ngwApiToAdapterOptions(_a) {
5857
5895
  'resource=' +
5858
5896
  resourceId +
5859
5897
  '&simplification=' +
5860
- (options.simplification || 0);
5898
+ ((_b = options.simplification) !== null && _b !== void 0 ? _b : 8);
5861
5899
  // url = baseUrl + '/api/resource/' + options.resourceId + '/{z}/{x}/{y}.mvt';
5862
5900
  return {
5863
5901
  url: url,
@@ -5925,7 +5963,6 @@ function createRasterAdapter(_a) {
5925
5963
  return [2 /*return*/, /** @class */ (function (_super) {
5926
5964
  __extends(RasterAdapter, _super);
5927
5965
  function RasterAdapter(map, _options) {
5928
- var _a;
5929
5966
  var _this = _super.call(this, map, _options) || this;
5930
5967
  _this.map = map;
5931
5968
  // options = {};
@@ -5937,7 +5974,7 @@ function createRasterAdapter(_a) {
5937
5974
  baseUrl: connector.options.baseUrl || '',
5938
5975
  });
5939
5976
  if (opt) {
5940
- var layerAdapterOptions = __assign(__assign({}, opt), { setViewDelay: (_a = layerOptions.adapterOptions) === null || _a === void 0 ? void 0 : _a.setViewDelay, params: { resource: resourceId_1 },
5977
+ var layerAdapterOptions = __assign(__assign(__assign({}, opt), layerOptions.adapterOptions), { params: { resource: resourceId_1 },
5941
5978
  // @deprecated
5942
5979
  layers: String(resourceId_1), resourceId: resourceId_1 });
5943
5980
  if (layerOptions.adapterOptions &&
@@ -5970,11 +6007,16 @@ function createRasterAdapter(_a) {
5970
6007
  return __awaiter(this, void 0, void 0, function () {
5971
6008
  var id;
5972
6009
  return __generator(this, function (_a) {
5973
- id = this.item && this.item.resource.parent.id;
5974
- if (defined(id)) {
5975
- return [2 /*return*/, [id]];
6010
+ if (this.item) {
6011
+ if (adapter === 'MVT') {
6012
+ return [2 /*return*/, [this.item.resource.id]];
6013
+ }
6014
+ id = this.item.resource.parent.id;
6015
+ if (defined(id)) {
6016
+ return [2 /*return*/, [id]];
6017
+ }
5976
6018
  }
5977
- return [2 /*return*/];
6019
+ return [2 /*return*/, []];
5978
6020
  });
5979
6021
  });
5980
6022
  };
@@ -7380,40 +7422,6 @@ function createWebMapAdapter(_a) {
7380
7422
  });
7381
7423
  }
7382
7424
 
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
7425
  var alias = {
7418
7426
  tms: 'TILE',
7419
7427
  };
@@ -7641,7 +7649,7 @@ function createAdapterFromFirstStyle(_a) {
7641
7649
  }
7642
7650
  function createAsyncAdapter(options, webMap, connector) {
7643
7651
  return __awaiter(this, void 0, void 0, function () {
7644
- var adapter, item, adapterType, resourceId, resourceOptions, itemFromResOpt, cls, layerOptions, adapterOptions, parentItem, parentOptions, getClassAdapter, classAdapter;
7652
+ var adapter, item, adapterType, resourceId, resourceOptions, itemFromResOpt, cls, layerOptions, adapterOptions, type, adapterOptions_, parentItem, parentOptions, getClassAdapter, classAdapter;
7645
7653
  return __generator(this, function (_a) {
7646
7654
  switch (_a.label) {
7647
7655
  case 0:
@@ -7677,6 +7685,12 @@ function createAsyncAdapter(options, webMap, connector) {
7677
7685
  return [3 /*break*/, 11];
7678
7686
  case 5:
7679
7687
  if (!(cls === 'vector_layer')) return [3 /*break*/, 6];
7688
+ type = item.vector_layer &&
7689
+ vectorLayerGeomToPaintTypeAlias[item.vector_layer.geometry_type];
7690
+ adapterOptions_ = adapterOptions.layerOptions.adapterOptions || {};
7691
+ adapterOptions_.type = adapterOptions_.type || type;
7692
+ adapterOptions.layerOptions.adapterOptions = adapterOptions_;
7693
+ options.adapterOptions = adapterOptions;
7680
7694
  if (adapterType !== undefined && adapterType !== 'GEOJSON') {
7681
7695
  if (adapterType === 'MVT') {
7682
7696
  adapter = createRasterAdapter(adapterOptions);
@@ -8857,7 +8871,7 @@ var NgwMap = /** @class */ (function (_super) {
8857
8871
  };
8858
8872
  NgwMap.prototype._selectFromNgwRaster = function (ev) {
8859
8873
  return __awaiter(this, void 0, void 0, function () {
8860
- var promises, layers, getIdsPromise, getIds, ids, pixelRadius, center, zoom, radius, selectPromise;
8874
+ var promises, layers, _i, layers_1, l, layer, identFunc, getIdsPromise, getIds, ids, pixelRadius, center, zoom, radius, selectPromise;
8861
8875
  var _this = this;
8862
8876
  return __generator(this, function (_a) {
8863
8877
  switch (_a.label) {
@@ -8871,15 +8885,16 @@ var NgwMap = /** @class */ (function (_super) {
8871
8885
  }
8872
8886
  return 1;
8873
8887
  });
8874
- layers.forEach(function (l) {
8875
- var layer = l.layer;
8876
- var identFunc = typeof layer.getIdentificationIds === 'function'
8888
+ for (_i = 0, layers_1 = layers; _i < layers_1.length; _i++) {
8889
+ l = layers_1[_i];
8890
+ layer = l.layer;
8891
+ identFunc = typeof layer.getIdentificationIds === 'function'
8877
8892
  ? layer.getIdentificationIds
8878
8893
  : false;
8879
- if (identFunc && layer.options.selectable && _this.isLayerVisible(layer)) {
8894
+ if (identFunc && layer.options.selectable && this.isLayerVisible(layer)) {
8880
8895
  promises.push(identFunc.call(layer));
8881
8896
  }
8882
- });
8897
+ }
8883
8898
  getIdsPromise = Promise.all(promises);
8884
8899
  return [4 /*yield*/, getIdsPromise];
8885
8900
  case 1: