@nextgis/ngw-map 1.13.7 → 1.15.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,5 +1,5 @@
1
- /** Bundle of @nextgis/ngw-map; version: 1.13.7; author: NextGIS */
2
- /*! *****************************************************************************
1
+ /** Bundle of @nextgis/ngw-map; version: 1.15.0; author: NextGIS */
2
+ /******************************************************************************
3
3
  Copyright (c) Microsoft Corporation.
4
4
 
5
5
  Permission to use, copy, modify, and/or distribute this software for any
@@ -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;
@@ -1858,7 +1861,7 @@ function clearObject(obj) {
1858
1861
  var ID$2 = 0;
1859
1862
  var OPTIONS$1 = {
1860
1863
  minZoom: 0,
1861
- maxZoom: 20,
1864
+ maxZoom: 22,
1862
1865
  paint: {
1863
1866
  color: '#0000ff',
1864
1867
  opacity: 0.4,
@@ -4434,6 +4437,29 @@ var ResourcesControl = /** @class */ (function () {
4434
4437
  return _this._getChildrenOf(parent, requestOptions);
4435
4438
  });
4436
4439
  };
4440
+ ResourcesControl.prototype.update = function (resource, data) {
4441
+ var _this = this;
4442
+ return this.getId(resource).then(function (id) {
4443
+ if (id !== undefined) {
4444
+ return _this.connector.put('resource.item', { data: data }, { id: id });
4445
+ }
4446
+ });
4447
+ };
4448
+ /**
4449
+ * Fast way to delete resource from NGW and clean cache.
4450
+ * @param resource - Resource definition
4451
+ */
4452
+ ResourcesControl.prototype.delete = function (resource) {
4453
+ var _this = this;
4454
+ return this.getId(resource).then(function (id) {
4455
+ if (id !== undefined) {
4456
+ return _this.connector.delete('resource.item', null, { id: id }).then(function () {
4457
+ _this._cleanResourceItemCache(id);
4458
+ return undefined;
4459
+ });
4460
+ }
4461
+ });
4462
+ };
4437
4463
  ResourcesControl.prototype._getChildrenOf = function (parent, requestOptions, _items) {
4438
4464
  var _this = this;
4439
4465
  if (_items === void 0) { _items = []; }
@@ -4461,29 +4487,6 @@ var ResourcesControl = /** @class */ (function () {
4461
4487
  return _items;
4462
4488
  });
4463
4489
  };
4464
- ResourcesControl.prototype.update = function (resource, data) {
4465
- var _this = this;
4466
- return this.getId(resource).then(function (id) {
4467
- if (id !== undefined) {
4468
- return _this.connector.put('resource.item', { data: data }, { id: id });
4469
- }
4470
- });
4471
- };
4472
- /**
4473
- * Fast way to delete resource from NGW and clean cache.
4474
- * @param resource - Resource definition
4475
- */
4476
- ResourcesControl.prototype.delete = function (resource) {
4477
- var _this = this;
4478
- return this.getId(resource).then(function (id) {
4479
- if (id !== undefined) {
4480
- return _this.connector.delete('resource.item', null, { id: id }).then(function () {
4481
- _this._cleanResourceItemCache(id);
4482
- return undefined;
4483
- });
4484
- }
4485
- });
4486
- };
4487
4490
  ResourcesControl.prototype._cleanResourceItemCache = function (id) {
4488
4491
  return __awaiter(this, void 0, void 0, function () {
4489
4492
  var all, toDelete, _i, all_1, c, cid, rid, _a, toDelete_1, d;
@@ -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 : 6);
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,29 +5974,13 @@ 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 },
5941
- // @deprecated
5942
- layers: String(resourceId_1), resourceId: resourceId_1 });
5977
+ var layerAdapterOptions = __assign(__assign(__assign({}, opt), layerOptions.adapterOptions), { params: { resource: resourceId_1 }, layers: opt.layers || String(resourceId_1), resourceId: resourceId_1 });
5943
5978
  if (layerOptions.adapterOptions &&
5944
5979
  defined(layerOptions.adapterOptions.setViewDelay)) {
5945
5980
  layerAdapterOptions.setViewDelay =
5946
5981
  layerOptions.adapterOptions.setViewDelay;
5947
5982
  }
5948
5983
  _this.options = __assign(__assign({}, _this.options), layerAdapterOptions);
5949
- // if (true) {
5950
- // Object.defineProperty(this.options, 'layers', {
5951
- // get: () => {
5952
- // console.warn('Do not use `layers` in ImageAdapterOptions');
5953
- // return String(resourceId);
5954
- // },
5955
- // });
5956
- // Object.defineProperty(this.options, 'resourceId', {
5957
- // get: () => {
5958
- // console.warn('Do not use `resourceId` in ImageAdapterOptions');
5959
- // return resourceId;
5960
- // },
5961
- // });
5962
- // }
5963
5984
  }
5964
5985
  return _this;
5965
5986
  }
@@ -5970,11 +5991,16 @@ function createRasterAdapter(_a) {
5970
5991
  return __awaiter(this, void 0, void 0, function () {
5971
5992
  var id;
5972
5993
  return __generator(this, function (_a) {
5973
- id = this.item && this.item.resource.parent.id;
5974
- if (defined(id)) {
5975
- return [2 /*return*/, [id]];
5994
+ if (this.item) {
5995
+ if (adapter === 'MVT') {
5996
+ return [2 /*return*/, [this.item.resource.id]];
5997
+ }
5998
+ id = this.item.resource.parent.id;
5999
+ if (defined(id)) {
6000
+ return [2 /*return*/, [id]];
6001
+ }
5976
6002
  }
5977
- return [2 /*return*/];
6003
+ return [2 /*return*/, []];
5978
6004
  });
5979
6005
  });
5980
6006
  };
@@ -7380,40 +7406,6 @@ function createWebMapAdapter(_a) {
7380
7406
  });
7381
7407
  }
7382
7408
 
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
7409
  var alias = {
7418
7410
  tms: 'TILE',
7419
7411
  };
@@ -7641,7 +7633,7 @@ function createAdapterFromFirstStyle(_a) {
7641
7633
  }
7642
7634
  function createAsyncAdapter(options, webMap, connector) {
7643
7635
  return __awaiter(this, void 0, void 0, function () {
7644
- var adapter, item, adapterType, resourceId, resourceOptions, itemFromResOpt, cls, layerOptions, adapterOptions, parentItem, parentOptions, getClassAdapter, classAdapter;
7636
+ var adapter, item, adapterType, resourceId, resourceOptions, itemFromResOpt, cls, layerOptions, adapterOptions, type, adapterOptions_, parentItem, parentOptions, getClassAdapter, classAdapter;
7645
7637
  return __generator(this, function (_a) {
7646
7638
  switch (_a.label) {
7647
7639
  case 0:
@@ -7677,6 +7669,12 @@ function createAsyncAdapter(options, webMap, connector) {
7677
7669
  return [3 /*break*/, 11];
7678
7670
  case 5:
7679
7671
  if (!(cls === 'vector_layer')) return [3 /*break*/, 6];
7672
+ type = item.vector_layer &&
7673
+ vectorLayerGeomToPaintTypeAlias[item.vector_layer.geometry_type];
7674
+ adapterOptions_ = adapterOptions.layerOptions.adapterOptions || {};
7675
+ adapterOptions_.type = adapterOptions_.type || type;
7676
+ adapterOptions.layerOptions.adapterOptions = adapterOptions_;
7677
+ options.adapterOptions = adapterOptions;
7680
7678
  if (adapterType !== undefined && adapterType !== 'GEOJSON') {
7681
7679
  if (adapterType === 'MVT') {
7682
7680
  adapter = createRasterAdapter(adapterOptions);
@@ -7786,10 +7784,8 @@ function extendNgwWebmapLayerAdapter(opt) {
7786
7784
  var A = /** @class */ (function (_super) {
7787
7785
  __extends(A, _super);
7788
7786
  function A(map, options) {
7789
- var _this = this;
7790
7787
  options = __assign(__assign({}, opt), options);
7791
- _this = _super.call(this, map, options) || this;
7792
- return _this;
7788
+ return _super.call(this, map, options) || this;
7793
7789
  }
7794
7790
  return A;
7795
7791
  }(NgwWebmapLayerAdapter));
@@ -8653,13 +8649,14 @@ var NgwMap = /** @class */ (function (_super) {
8653
8649
  var _this = this;
8654
8650
  if (!this.$$selectFromNgwRaster) {
8655
8651
  this.$$selectFromNgwRaster = function (ev) {
8656
- var count = _this.emitter.listenerCount('ngw:select');
8652
+ var count = _this._getSelectListenersCount();
8657
8653
  if (count) {
8658
8654
  _this._selectFromNgwRaster(ev);
8659
8655
  }
8660
8656
  };
8661
8657
  this.$$selectFromNgwVector = function (ev) {
8662
- if (_this.emitter.listenerCount('ngw:select')) {
8658
+ var count = _this._getSelectListenersCount();
8659
+ if (count) {
8663
8660
  _this._selectFromNgwVector(ev);
8664
8661
  }
8665
8662
  };
@@ -8670,8 +8667,10 @@ var NgwMap = /** @class */ (function (_super) {
8670
8667
  NgwMap.prototype.disableSelection = function () {
8671
8668
  if (this.$$selectFromNgwRaster) {
8672
8669
  this.emitter.removeListener('click', this.$$selectFromNgwRaster);
8673
- this.emitter.removeListener('click', this._selectFromNgwVector);
8674
8670
  this.$$selectFromNgwRaster = undefined;
8671
+ }
8672
+ if (this.$$selectFromNgwVector) {
8673
+ this.emitter.removeListener('layer:click', this.$$selectFromNgwVector);
8675
8674
  this.$$selectFromNgwVector = undefined;
8676
8675
  }
8677
8676
  };
@@ -8827,7 +8826,11 @@ var NgwMap = /** @class */ (function (_super) {
8827
8826
  NgwMap.prototype._selectFromNgwVector = function (ev) {
8828
8827
  var _a;
8829
8828
  var layer = ev.layer;
8830
- // item property means layer is NgwResource
8829
+ var selectable = layer.options.selectable && this.isLayerVisible(layer);
8830
+ if (!selectable) {
8831
+ return undefined;
8832
+ }
8833
+ // Item property means layer is NgwResource
8831
8834
  var id = layer.item && layer.item.resource.id;
8832
8835
  var feature = ev.feature;
8833
8836
  if (id !== undefined && feature) {
@@ -8857,10 +8860,10 @@ var NgwMap = /** @class */ (function (_super) {
8857
8860
  };
8858
8861
  NgwMap.prototype._selectFromNgwRaster = function (ev) {
8859
8862
  return __awaiter(this, void 0, void 0, function () {
8860
- var promises, layers, getIdsPromise, getIds, ids, pixelRadius, center, zoom, radius, selectPromise;
8863
+ var promises, layers, _i, layers_1, l, layer, identFunc, getIdsPromise, getIds, ids, _a, getIds_1, x, pixelRadius, center, zoom, radius, selectPromise;
8861
8864
  var _this = this;
8862
- return __generator(this, function (_a) {
8863
- switch (_a.label) {
8865
+ return __generator(this, function (_b) {
8866
+ switch (_b.label) {
8864
8867
  case 0:
8865
8868
  this._emitStatusEvent('ngw:preselect');
8866
8869
  promises = [];
@@ -8871,25 +8874,27 @@ var NgwMap = /** @class */ (function (_super) {
8871
8874
  }
8872
8875
  return 1;
8873
8876
  });
8874
- layers.forEach(function (l) {
8875
- var layer = l.layer;
8876
- var identFunc = typeof layer.getIdentificationIds === 'function'
8877
+ for (_i = 0, layers_1 = layers; _i < layers_1.length; _i++) {
8878
+ l = layers_1[_i];
8879
+ layer = l.layer;
8880
+ identFunc = typeof layer.getIdentificationIds === 'function'
8877
8881
  ? layer.getIdentificationIds
8878
8882
  : false;
8879
- if (identFunc && layer.options.selectable && _this.isLayerVisible(layer)) {
8883
+ if (identFunc && layer.options.selectable && this.isLayerVisible(layer)) {
8880
8884
  promises.push(identFunc.call(layer));
8881
8885
  }
8882
- });
8886
+ }
8883
8887
  getIdsPromise = Promise.all(promises);
8884
8888
  return [4 /*yield*/, getIdsPromise];
8885
8889
  case 1:
8886
- getIds = _a.sent();
8890
+ getIds = _b.sent();
8887
8891
  ids = [];
8888
- getIds.forEach(function (x) {
8892
+ for (_a = 0, getIds_1 = getIds; _a < getIds_1.length; _a++) {
8893
+ x = getIds_1[_a];
8889
8894
  if (x) {
8890
- x.forEach(function (y) { return ids.push(y); });
8895
+ ids.push.apply(ids, x);
8891
8896
  }
8892
- });
8897
+ }
8893
8898
  if (!ids.length) {
8894
8899
  this._emitStatusEvent('ngw:select', null);
8895
8900
  return [2 /*return*/];
@@ -8929,6 +8934,9 @@ var NgwMap = /** @class */ (function (_super) {
8929
8934
  };
8930
8935
  return __assign(__assign({}, identify), { getIdentifyItems: getIdentifyItems_ });
8931
8936
  };
8937
+ NgwMap.prototype._getSelectListenersCount = function () {
8938
+ return this.emitter.listenerCount('ngw:select');
8939
+ };
8932
8940
  NgwMap.prototype._whiteLabel = function () {
8933
8941
  return __awaiter(this, void 0, void 0, function () {
8934
8942
  var container, logo;