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