@nextgis/ngw-map 1.13.6 → 1.14.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,4 +1,4 @@
1
- /** Bundle of @nextgis/ngw-map; version: 1.13.6; author: NextGIS */
1
+ /** Bundle of @nextgis/ngw-map; version: 1.14.0; 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;
@@ -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,
@@ -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,10 +5898,12 @@ 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,
5905
+ sourceLayer: 'ngw:' + resourceId,
5906
+ featureIdName: '$id',
5867
5907
  };
5868
5908
  }
5869
5909
  if (adapter === 'TERRAIN') {
@@ -5926,7 +5966,6 @@ var NgwMap = (function (exports) {
5926
5966
  return [2 /*return*/, /** @class */ (function (_super) {
5927
5967
  __extends(RasterAdapter, _super);
5928
5968
  function RasterAdapter(map, _options) {
5929
- var _a;
5930
5969
  var _this = _super.call(this, map, _options) || this;
5931
5970
  _this.map = map;
5932
5971
  // options = {};
@@ -5938,29 +5977,13 @@ var NgwMap = (function (exports) {
5938
5977
  baseUrl: connector.options.baseUrl || '',
5939
5978
  });
5940
5979
  if (opt) {
5941
- var layerAdapterOptions = __assign(__assign({}, opt), { setViewDelay: (_a = layerOptions.adapterOptions) === null || _a === void 0 ? void 0 : _a.setViewDelay, params: { resource: resourceId_1 },
5942
- // @deprecated
5943
- 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 });
5944
5981
  if (layerOptions.adapterOptions &&
5945
5982
  defined(layerOptions.adapterOptions.setViewDelay)) {
5946
5983
  layerAdapterOptions.setViewDelay =
5947
5984
  layerOptions.adapterOptions.setViewDelay;
5948
5985
  }
5949
5986
  _this.options = __assign(__assign({}, _this.options), layerAdapterOptions);
5950
- // if (true) {
5951
- // Object.defineProperty(this.options, 'layers', {
5952
- // get: () => {
5953
- // console.warn('Do not use `layers` in ImageAdapterOptions');
5954
- // return String(resourceId);
5955
- // },
5956
- // });
5957
- // Object.defineProperty(this.options, 'resourceId', {
5958
- // get: () => {
5959
- // console.warn('Do not use `resourceId` in ImageAdapterOptions');
5960
- // return resourceId;
5961
- // },
5962
- // });
5963
- // }
5964
5987
  }
5965
5988
  return _this;
5966
5989
  }
@@ -5971,11 +5994,16 @@ var NgwMap = (function (exports) {
5971
5994
  return __awaiter(this, void 0, void 0, function () {
5972
5995
  var id;
5973
5996
  return __generator(this, function (_a) {
5974
- id = this.item && this.item.resource.parent.id;
5975
- if (defined(id)) {
5976
- 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
+ }
5977
6005
  }
5978
- return [2 /*return*/];
6006
+ return [2 /*return*/, []];
5979
6007
  });
5980
6008
  });
5981
6009
  };
@@ -7381,40 +7409,6 @@ var NgwMap = (function (exports) {
7381
7409
  });
7382
7410
  }
7383
7411
 
7384
- var NgwResource = /** @class */ (function () {
7385
- function NgwResource() {
7386
- }
7387
- /** @deprecated use {@link NgwResource.getBounds} instead */
7388
- NgwResource.prototype.getExtent = function () {
7389
- return __awaiter(this, void 0, void 0, function () {
7390
- return __generator(this, function (_a) {
7391
- return [2 /*return*/, this.getBounds()];
7392
- });
7393
- });
7394
- };
7395
- NgwResource.prototype.getBounds = function (options) {
7396
- return __awaiter(this, void 0, void 0, function () {
7397
- var _a;
7398
- return __generator(this, function (_b) {
7399
- switch (_b.label) {
7400
- case 0:
7401
- if (this._extent) {
7402
- return [2 /*return*/, this._extent];
7403
- }
7404
- if (!this.item) return [3 /*break*/, 2];
7405
- _a = this;
7406
- return [4 /*yield*/, fetchNgwResourceExtent(this.item, this.connector, options)];
7407
- case 1:
7408
- _a._extent = _b.sent();
7409
- return [2 /*return*/, this._extent];
7410
- case 2: return [2 /*return*/];
7411
- }
7412
- });
7413
- });
7414
- };
7415
- return NgwResource;
7416
- }());
7417
-
7418
7412
  var alias = {
7419
7413
  tms: 'TILE',
7420
7414
  };
@@ -7642,7 +7636,7 @@ var NgwMap = (function (exports) {
7642
7636
  }
7643
7637
  function createAsyncAdapter(options, webMap, connector) {
7644
7638
  return __awaiter(this, void 0, void 0, function () {
7645
- 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;
7646
7640
  return __generator(this, function (_a) {
7647
7641
  switch (_a.label) {
7648
7642
  case 0:
@@ -7678,6 +7672,12 @@ var NgwMap = (function (exports) {
7678
7672
  return [3 /*break*/, 11];
7679
7673
  case 5:
7680
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;
7681
7681
  if (adapterType !== undefined && adapterType !== 'GEOJSON') {
7682
7682
  if (adapterType === 'MVT') {
7683
7683
  adapter = createRasterAdapter(adapterOptions);
@@ -8654,13 +8654,14 @@ var NgwMap = (function (exports) {
8654
8654
  var _this = this;
8655
8655
  if (!this.$$selectFromNgwRaster) {
8656
8656
  this.$$selectFromNgwRaster = function (ev) {
8657
- var count = _this.emitter.listenerCount('ngw:select');
8657
+ var count = _this._getSelectListenersCount();
8658
8658
  if (count) {
8659
8659
  _this._selectFromNgwRaster(ev);
8660
8660
  }
8661
8661
  };
8662
8662
  this.$$selectFromNgwVector = function (ev) {
8663
- if (_this.emitter.listenerCount('ngw:select')) {
8663
+ var count = _this._getSelectListenersCount();
8664
+ if (count) {
8664
8665
  _this._selectFromNgwVector(ev);
8665
8666
  }
8666
8667
  };
@@ -8671,8 +8672,10 @@ var NgwMap = (function (exports) {
8671
8672
  NgwMap.prototype.disableSelection = function () {
8672
8673
  if (this.$$selectFromNgwRaster) {
8673
8674
  this.emitter.removeListener('click', this.$$selectFromNgwRaster);
8674
- this.emitter.removeListener('click', this._selectFromNgwVector);
8675
8675
  this.$$selectFromNgwRaster = undefined;
8676
+ }
8677
+ if (this.$$selectFromNgwVector) {
8678
+ this.emitter.removeListener('layer:click', this.$$selectFromNgwVector);
8676
8679
  this.$$selectFromNgwVector = undefined;
8677
8680
  }
8678
8681
  };
@@ -8828,7 +8831,11 @@ var NgwMap = (function (exports) {
8828
8831
  NgwMap.prototype._selectFromNgwVector = function (ev) {
8829
8832
  var _a;
8830
8833
  var layer = ev.layer;
8831
- // item property means layer is NgwResource
8834
+ var selectable = layer.options.selectable && this.isLayerVisible(layer);
8835
+ if (!selectable) {
8836
+ return undefined;
8837
+ }
8838
+ // Item property means layer is NgwResource
8832
8839
  var id = layer.item && layer.item.resource.id;
8833
8840
  var feature = ev.feature;
8834
8841
  if (id !== undefined && feature) {
@@ -8858,10 +8865,10 @@ var NgwMap = (function (exports) {
8858
8865
  };
8859
8866
  NgwMap.prototype._selectFromNgwRaster = function (ev) {
8860
8867
  return __awaiter(this, void 0, void 0, function () {
8861
- var promises, layers, getIdsPromise, getIds, ids, pixelRadius, center, zoom, radius, selectPromise;
8868
+ var promises, layers, _i, layers_1, l, layer, identFunc, getIdsPromise, getIds, ids, _a, getIds_1, x, pixelRadius, center, zoom, radius, selectPromise;
8862
8869
  var _this = this;
8863
- return __generator(this, function (_a) {
8864
- switch (_a.label) {
8870
+ return __generator(this, function (_b) {
8871
+ switch (_b.label) {
8865
8872
  case 0:
8866
8873
  this._emitStatusEvent('ngw:preselect');
8867
8874
  promises = [];
@@ -8872,25 +8879,27 @@ var NgwMap = (function (exports) {
8872
8879
  }
8873
8880
  return 1;
8874
8881
  });
8875
- layers.forEach(function (l) {
8876
- var layer = l.layer;
8877
- var identFunc = typeof layer.getIdentificationIds === 'function'
8882
+ for (_i = 0, layers_1 = layers; _i < layers_1.length; _i++) {
8883
+ l = layers_1[_i];
8884
+ layer = l.layer;
8885
+ identFunc = typeof layer.getIdentificationIds === 'function'
8878
8886
  ? layer.getIdentificationIds
8879
8887
  : false;
8880
- if (identFunc && layer.options.selectable && _this.isLayerVisible(layer)) {
8888
+ if (identFunc && layer.options.selectable && this.isLayerVisible(layer)) {
8881
8889
  promises.push(identFunc.call(layer));
8882
8890
  }
8883
- });
8891
+ }
8884
8892
  getIdsPromise = Promise.all(promises);
8885
8893
  return [4 /*yield*/, getIdsPromise];
8886
8894
  case 1:
8887
- getIds = _a.sent();
8895
+ getIds = _b.sent();
8888
8896
  ids = [];
8889
- getIds.forEach(function (x) {
8897
+ for (_a = 0, getIds_1 = getIds; _a < getIds_1.length; _a++) {
8898
+ x = getIds_1[_a];
8890
8899
  if (x) {
8891
- x.forEach(function (y) { return ids.push(y); });
8900
+ ids.push.apply(ids, x);
8892
8901
  }
8893
- });
8902
+ }
8894
8903
  if (!ids.length) {
8895
8904
  this._emitStatusEvent('ngw:select', null);
8896
8905
  return [2 /*return*/];
@@ -8930,6 +8939,9 @@ var NgwMap = (function (exports) {
8930
8939
  };
8931
8940
  return __assign(__assign({}, identify), { getIdentifyItems: getIdentifyItems_ });
8932
8941
  };
8942
+ NgwMap.prototype._getSelectListenersCount = function () {
8943
+ return this.emitter.listenerCount('ngw:select');
8944
+ };
8933
8945
  NgwMap.prototype._whiteLabel = function () {
8934
8946
  return __awaiter(this, void 0, void 0, function () {
8935
8947
  var container, logo;