@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
  /*! *****************************************************************************
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;
@@ -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,
@@ -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,10 +5895,12 @@ 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,
5902
+ sourceLayer: 'ngw:' + resourceId,
5903
+ featureIdName: '$id',
5864
5904
  };
5865
5905
  }
5866
5906
  if (adapter === 'TERRAIN') {
@@ -5923,7 +5963,6 @@ function createRasterAdapter(_a) {
5923
5963
  return [2 /*return*/, /** @class */ (function (_super) {
5924
5964
  __extends(RasterAdapter, _super);
5925
5965
  function RasterAdapter(map, _options) {
5926
- var _a;
5927
5966
  var _this = _super.call(this, map, _options) || this;
5928
5967
  _this.map = map;
5929
5968
  // options = {};
@@ -5935,29 +5974,13 @@ function createRasterAdapter(_a) {
5935
5974
  baseUrl: connector.options.baseUrl || '',
5936
5975
  });
5937
5976
  if (opt) {
5938
- var layerAdapterOptions = __assign(__assign({}, opt), { setViewDelay: (_a = layerOptions.adapterOptions) === null || _a === void 0 ? void 0 : _a.setViewDelay, params: { resource: resourceId_1 },
5939
- // @deprecated
5940
- 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 });
5941
5978
  if (layerOptions.adapterOptions &&
5942
5979
  defined(layerOptions.adapterOptions.setViewDelay)) {
5943
5980
  layerAdapterOptions.setViewDelay =
5944
5981
  layerOptions.adapterOptions.setViewDelay;
5945
5982
  }
5946
5983
  _this.options = __assign(__assign({}, _this.options), layerAdapterOptions);
5947
- // if (true) {
5948
- // Object.defineProperty(this.options, 'layers', {
5949
- // get: () => {
5950
- // console.warn('Do not use `layers` in ImageAdapterOptions');
5951
- // return String(resourceId);
5952
- // },
5953
- // });
5954
- // Object.defineProperty(this.options, 'resourceId', {
5955
- // get: () => {
5956
- // console.warn('Do not use `resourceId` in ImageAdapterOptions');
5957
- // return resourceId;
5958
- // },
5959
- // });
5960
- // }
5961
5984
  }
5962
5985
  return _this;
5963
5986
  }
@@ -5968,11 +5991,16 @@ function createRasterAdapter(_a) {
5968
5991
  return __awaiter(this, void 0, void 0, function () {
5969
5992
  var id;
5970
5993
  return __generator(this, function (_a) {
5971
- id = this.item && this.item.resource.parent.id;
5972
- if (defined(id)) {
5973
- 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
+ }
5974
6002
  }
5975
- return [2 /*return*/];
6003
+ return [2 /*return*/, []];
5976
6004
  });
5977
6005
  });
5978
6006
  };
@@ -7378,40 +7406,6 @@ function createWebMapAdapter(_a) {
7378
7406
  });
7379
7407
  }
7380
7408
 
7381
- var NgwResource = /** @class */ (function () {
7382
- function NgwResource() {
7383
- }
7384
- /** @deprecated use {@link NgwResource.getBounds} instead */
7385
- NgwResource.prototype.getExtent = function () {
7386
- return __awaiter(this, void 0, void 0, function () {
7387
- return __generator(this, function (_a) {
7388
- return [2 /*return*/, this.getBounds()];
7389
- });
7390
- });
7391
- };
7392
- NgwResource.prototype.getBounds = function (options) {
7393
- return __awaiter(this, void 0, void 0, function () {
7394
- var _a;
7395
- return __generator(this, function (_b) {
7396
- switch (_b.label) {
7397
- case 0:
7398
- if (this._extent) {
7399
- return [2 /*return*/, this._extent];
7400
- }
7401
- if (!this.item) return [3 /*break*/, 2];
7402
- _a = this;
7403
- return [4 /*yield*/, fetchNgwResourceExtent(this.item, this.connector, options)];
7404
- case 1:
7405
- _a._extent = _b.sent();
7406
- return [2 /*return*/, this._extent];
7407
- case 2: return [2 /*return*/];
7408
- }
7409
- });
7410
- });
7411
- };
7412
- return NgwResource;
7413
- }());
7414
-
7415
7409
  var alias = {
7416
7410
  tms: 'TILE',
7417
7411
  };
@@ -7639,7 +7633,7 @@ function createAdapterFromFirstStyle(_a) {
7639
7633
  }
7640
7634
  function createAsyncAdapter(options, webMap, connector) {
7641
7635
  return __awaiter(this, void 0, void 0, function () {
7642
- 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;
7643
7637
  return __generator(this, function (_a) {
7644
7638
  switch (_a.label) {
7645
7639
  case 0:
@@ -7675,6 +7669,12 @@ function createAsyncAdapter(options, webMap, connector) {
7675
7669
  return [3 /*break*/, 11];
7676
7670
  case 5:
7677
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;
7678
7678
  if (adapterType !== undefined && adapterType !== 'GEOJSON') {
7679
7679
  if (adapterType === 'MVT') {
7680
7680
  adapter = createRasterAdapter(adapterOptions);
@@ -8651,13 +8651,14 @@ var NgwMap = /** @class */ (function (_super) {
8651
8651
  var _this = this;
8652
8652
  if (!this.$$selectFromNgwRaster) {
8653
8653
  this.$$selectFromNgwRaster = function (ev) {
8654
- var count = _this.emitter.listenerCount('ngw:select');
8654
+ var count = _this._getSelectListenersCount();
8655
8655
  if (count) {
8656
8656
  _this._selectFromNgwRaster(ev);
8657
8657
  }
8658
8658
  };
8659
8659
  this.$$selectFromNgwVector = function (ev) {
8660
- if (_this.emitter.listenerCount('ngw:select')) {
8660
+ var count = _this._getSelectListenersCount();
8661
+ if (count) {
8661
8662
  _this._selectFromNgwVector(ev);
8662
8663
  }
8663
8664
  };
@@ -8668,8 +8669,10 @@ var NgwMap = /** @class */ (function (_super) {
8668
8669
  NgwMap.prototype.disableSelection = function () {
8669
8670
  if (this.$$selectFromNgwRaster) {
8670
8671
  this.emitter.removeListener('click', this.$$selectFromNgwRaster);
8671
- this.emitter.removeListener('click', this._selectFromNgwVector);
8672
8672
  this.$$selectFromNgwRaster = undefined;
8673
+ }
8674
+ if (this.$$selectFromNgwVector) {
8675
+ this.emitter.removeListener('layer:click', this.$$selectFromNgwVector);
8673
8676
  this.$$selectFromNgwVector = undefined;
8674
8677
  }
8675
8678
  };
@@ -8825,7 +8828,11 @@ var NgwMap = /** @class */ (function (_super) {
8825
8828
  NgwMap.prototype._selectFromNgwVector = function (ev) {
8826
8829
  var _a;
8827
8830
  var layer = ev.layer;
8828
- // item property means layer is NgwResource
8831
+ var selectable = layer.options.selectable && this.isLayerVisible(layer);
8832
+ if (!selectable) {
8833
+ return undefined;
8834
+ }
8835
+ // Item property means layer is NgwResource
8829
8836
  var id = layer.item && layer.item.resource.id;
8830
8837
  var feature = ev.feature;
8831
8838
  if (id !== undefined && feature) {
@@ -8855,10 +8862,10 @@ var NgwMap = /** @class */ (function (_super) {
8855
8862
  };
8856
8863
  NgwMap.prototype._selectFromNgwRaster = function (ev) {
8857
8864
  return __awaiter(this, void 0, void 0, function () {
8858
- var promises, layers, getIdsPromise, getIds, ids, pixelRadius, center, zoom, radius, selectPromise;
8865
+ var promises, layers, _i, layers_1, l, layer, identFunc, getIdsPromise, getIds, ids, _a, getIds_1, x, pixelRadius, center, zoom, radius, selectPromise;
8859
8866
  var _this = this;
8860
- return __generator(this, function (_a) {
8861
- switch (_a.label) {
8867
+ return __generator(this, function (_b) {
8868
+ switch (_b.label) {
8862
8869
  case 0:
8863
8870
  this._emitStatusEvent('ngw:preselect');
8864
8871
  promises = [];
@@ -8869,25 +8876,27 @@ var NgwMap = /** @class */ (function (_super) {
8869
8876
  }
8870
8877
  return 1;
8871
8878
  });
8872
- layers.forEach(function (l) {
8873
- var layer = l.layer;
8874
- var identFunc = typeof layer.getIdentificationIds === 'function'
8879
+ for (_i = 0, layers_1 = layers; _i < layers_1.length; _i++) {
8880
+ l = layers_1[_i];
8881
+ layer = l.layer;
8882
+ identFunc = typeof layer.getIdentificationIds === 'function'
8875
8883
  ? layer.getIdentificationIds
8876
8884
  : false;
8877
- if (identFunc && layer.options.selectable && _this.isLayerVisible(layer)) {
8885
+ if (identFunc && layer.options.selectable && this.isLayerVisible(layer)) {
8878
8886
  promises.push(identFunc.call(layer));
8879
8887
  }
8880
- });
8888
+ }
8881
8889
  getIdsPromise = Promise.all(promises);
8882
8890
  return [4 /*yield*/, getIdsPromise];
8883
8891
  case 1:
8884
- getIds = _a.sent();
8892
+ getIds = _b.sent();
8885
8893
  ids = [];
8886
- getIds.forEach(function (x) {
8894
+ for (_a = 0, getIds_1 = getIds; _a < getIds_1.length; _a++) {
8895
+ x = getIds_1[_a];
8887
8896
  if (x) {
8888
- x.forEach(function (y) { return ids.push(y); });
8897
+ ids.push.apply(ids, x);
8889
8898
  }
8890
- });
8899
+ }
8891
8900
  if (!ids.length) {
8892
8901
  this._emitStatusEvent('ngw:select', null);
8893
8902
  return [2 /*return*/];
@@ -8927,6 +8936,9 @@ var NgwMap = /** @class */ (function (_super) {
8927
8936
  };
8928
8937
  return __assign(__assign({}, identify), { getIdentifyItems: getIdentifyItems_ });
8929
8938
  };
8939
+ NgwMap.prototype._getSelectListenersCount = function () {
8940
+ return this.emitter.listenerCount('ngw:select');
8941
+ };
8930
8942
  NgwMap.prototype._whiteLabel = function () {
8931
8943
  return __awaiter(this, void 0, void 0, function () {
8932
8944
  var container, logo;