@nextgis/ngw-leaflet 1.13.5 → 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-leaflet; version: 1.13.5; author: NextGIS */
1
+ /** Bundle of @nextgis/ngw-leaflet; version: 1.13.8; author: NextGIS */
2
2
  /*! *****************************************************************************
3
3
  Copyright (c) Microsoft Corporation.
4
4
 
@@ -15594,16 +15594,17 @@ function updatePaintOptionFromCallback(paint, getPaintFunctions) {
15594
15594
  function createPropertiesPaint(propertiesPaint) {
15595
15595
  var mask = {};
15596
15596
  var paintsFilters = [];
15597
- propertiesPaint.forEach(function (x) {
15598
- if (x) {
15599
- if (Array.isArray(x)) {
15600
- paintsFilters.push(x);
15597
+ for (var _i = 0, propertiesPaint_1 = propertiesPaint; _i < propertiesPaint_1.length; _i++) {
15598
+ var p = propertiesPaint_1[_i];
15599
+ if (p) {
15600
+ if (Array.isArray(p)) {
15601
+ paintsFilters.push(p);
15601
15602
  }
15602
15603
  else {
15603
- mask = x;
15604
+ mask = p;
15604
15605
  }
15605
15606
  }
15606
- });
15607
+ }
15607
15608
  return function (feature) {
15608
15609
  var paint = paintsFilters.find(function (x) { return featureFilter(feature, x[0]); });
15609
15610
  if (paint) {
@@ -15643,9 +15644,11 @@ function preparePaint(paint, defaultPaint, getPaintFunctions) {
15643
15644
  else {
15644
15645
  var expressionCallback_1 = createExpressionCallback(paint);
15645
15646
  if (expressionCallback_1) {
15646
- return function (feature) {
15647
+ var expressionPaintCb = function (feature) {
15647
15648
  return preparePaint(expressionCallback_1(feature), defaultPaint, getPaintFunctions);
15648
15649
  };
15650
+ expressionPaintCb.paint = paint;
15651
+ return expressionPaintCb;
15649
15652
  }
15650
15653
  newPaint = __assign(__assign({}, newPaint), paint);
15651
15654
  newPaint.fill = newPaint.fill !== undefined ? newPaint.fill : true;
@@ -16916,6 +16919,7 @@ var WebMapLayers = /** @class */ (function (_super) {
16916
16919
  };
16917
16920
  /** Shortcut for {@link WebMapLayers.addLayer} to create TileLayer adapter */
16918
16921
  WebMapLayers.prototype.addTileLayer = function (url, options) {
16922
+ if (options === void 0) { options = {}; }
16919
16923
  return this.addLayer('TILE', __assign(__assign({}, options), { url: url }));
16920
16924
  };
16921
16925
  WebMapLayers.prototype.addImageLayer = function (urlOrOptions, options) {
@@ -19129,51 +19133,6 @@ var NgwConnector = /** @class */ (function () {
19129
19133
  return NgwConnector;
19130
19134
  }());
19131
19135
 
19132
- function createPopupContent(feature, item) {
19133
- // @ts-ignore
19134
- {
19135
- var element_1 = document.createElement('div');
19136
- if (item && item.feature_layer) {
19137
- item.feature_layer.fields.forEach(function (x) {
19138
- if (x.grid_visibility) {
19139
- var value = feature.properties && feature.properties[x.keyname];
19140
- if (value) {
19141
- var propElem = document.createElement('div');
19142
- element_1.appendChild(propElem);
19143
- propElem.innerHTML = "<span>".concat(x.display_name, "</span>: ").concat(value, "<span></span>");
19144
- }
19145
- }
19146
- });
19147
- }
19148
- else if (feature.properties) {
19149
- for (var p in feature.properties) {
19150
- var propElem = document.createElement('div');
19151
- element_1.appendChild(propElem);
19152
- propElem.innerHTML = "<span>".concat(p, "</span>: ").concat(feature.properties[p], "<span></span>");
19153
- }
19154
- }
19155
- return element_1;
19156
- }
19157
- }
19158
-
19159
- var filterOptionsKeys = [
19160
- 'fields',
19161
- 'intersects',
19162
- 'limit',
19163
- 'orderBy',
19164
- 'strategy',
19165
- ];
19166
- function getLayerFilterOptions(options) {
19167
- var filterOptions = {};
19168
- filterOptionsKeys.forEach(function (x) {
19169
- var opt = options[x];
19170
- if (opt !== undefined) {
19171
- filterOptions[x] = opt;
19172
- }
19173
- });
19174
- return filterOptions;
19175
- }
19176
-
19177
19136
  function getNgwWebmapExtent(webmap) {
19178
19137
  var bottom = webmap['extent_bottom'];
19179
19138
  var left = webmap['extent_left'];
@@ -19241,6 +19200,85 @@ function fetchNgwResourceExtent(item, connector, options) {
19241
19200
  }
19242
19201
  }
19243
19202
 
19203
+ var NgwResource = /** @class */ (function () {
19204
+ function NgwResource() {
19205
+ }
19206
+ /** @deprecated use {@link NgwResource.getBounds} instead */
19207
+ NgwResource.prototype.getExtent = function () {
19208
+ return __awaiter(this, void 0, void 0, function () {
19209
+ return __generator(this, function (_a) {
19210
+ return [2 /*return*/, this.getBounds()];
19211
+ });
19212
+ });
19213
+ };
19214
+ NgwResource.prototype.getBounds = function (options) {
19215
+ return __awaiter(this, void 0, void 0, function () {
19216
+ var _a;
19217
+ return __generator(this, function (_b) {
19218
+ switch (_b.label) {
19219
+ case 0:
19220
+ if (this._extent) {
19221
+ return [2 /*return*/, this._extent];
19222
+ }
19223
+ if (!this.item) return [3 /*break*/, 2];
19224
+ _a = this;
19225
+ return [4 /*yield*/, fetchNgwResourceExtent(this.item, this.connector, options)];
19226
+ case 1:
19227
+ _a._extent = _b.sent();
19228
+ return [2 /*return*/, this._extent];
19229
+ case 2: return [2 /*return*/];
19230
+ }
19231
+ });
19232
+ });
19233
+ };
19234
+ return NgwResource;
19235
+ }());
19236
+
19237
+ function createPopupContent(feature, item) {
19238
+ // @ts-ignore
19239
+ {
19240
+ var element_1 = document.createElement('div');
19241
+ if (item && item.feature_layer) {
19242
+ item.feature_layer.fields.forEach(function (x) {
19243
+ if (x.grid_visibility) {
19244
+ var value = feature.properties && feature.properties[x.keyname];
19245
+ if (value) {
19246
+ var propElem = document.createElement('div');
19247
+ element_1.appendChild(propElem);
19248
+ propElem.innerHTML = "<span>".concat(x.display_name, "</span>: ").concat(value, "<span></span>");
19249
+ }
19250
+ }
19251
+ });
19252
+ }
19253
+ else if (feature.properties) {
19254
+ for (var p in feature.properties) {
19255
+ var propElem = document.createElement('div');
19256
+ element_1.appendChild(propElem);
19257
+ propElem.innerHTML = "<span>".concat(p, "</span>: ").concat(feature.properties[p], "<span></span>");
19258
+ }
19259
+ }
19260
+ return element_1;
19261
+ }
19262
+ }
19263
+
19264
+ var filterOptionsKeys = [
19265
+ 'fields',
19266
+ 'intersects',
19267
+ 'limit',
19268
+ 'orderBy',
19269
+ 'strategy',
19270
+ ];
19271
+ function getLayerFilterOptions(options) {
19272
+ var filterOptions = {};
19273
+ filterOptionsKeys.forEach(function (x) {
19274
+ var opt = options[x];
19275
+ if (opt !== undefined) {
19276
+ filterOptions[x] = opt;
19277
+ }
19278
+ });
19279
+ return filterOptions;
19280
+ }
19281
+
19244
19282
  function resourceIdFromLayerOptions(options, connector) {
19245
19283
  return __awaiter(this, void 0, void 0, function () {
19246
19284
  var resource, item, keyname, resourceId, resourceItem;
@@ -19878,6 +19916,7 @@ function getImageAdapterOptions(_a) {
19878
19916
  };
19879
19917
  }
19880
19918
  function ngwApiToAdapterOptions(_a) {
19919
+ var _b;
19881
19920
  var options = _a.options, webMap = _a.webMap, baseUrl = _a.baseUrl;
19882
19921
  var adapter = options.adapter || 'IMAGE';
19883
19922
  var url;
@@ -19917,10 +19956,12 @@ function ngwApiToAdapterOptions(_a) {
19917
19956
  'resource=' +
19918
19957
  resourceId +
19919
19958
  '&simplification=' +
19920
- (options.simplification || 0);
19959
+ ((_b = options.simplification) !== null && _b !== void 0 ? _b : 8);
19921
19960
  // url = baseUrl + '/api/resource/' + options.resourceId + '/{z}/{x}/{y}.mvt';
19922
19961
  return {
19923
19962
  url: url,
19963
+ sourceLayer: 'ngw:' + resourceId,
19964
+ featureIdName: '$id',
19924
19965
  };
19925
19966
  }
19926
19967
  if (adapter === 'TERRAIN') {
@@ -19983,7 +20024,6 @@ function createRasterAdapter(_a) {
19983
20024
  return [2 /*return*/, /** @class */ (function (_super) {
19984
20025
  __extends(RasterAdapter, _super);
19985
20026
  function RasterAdapter(map, _options) {
19986
- var _a;
19987
20027
  var _this = _super.call(this, map, _options) || this;
19988
20028
  _this.map = map;
19989
20029
  // options = {};
@@ -19995,7 +20035,7 @@ function createRasterAdapter(_a) {
19995
20035
  baseUrl: connector.options.baseUrl || '',
19996
20036
  });
19997
20037
  if (opt) {
19998
- var layerAdapterOptions = __assign(__assign({}, opt), { setViewDelay: (_a = layerOptions.adapterOptions) === null || _a === void 0 ? void 0 : _a.setViewDelay, params: { resource: resourceId_1 },
20038
+ var layerAdapterOptions = __assign(__assign(__assign({}, opt), layerOptions.adapterOptions), { params: { resource: resourceId_1 },
19999
20039
  // @deprecated
20000
20040
  layers: String(resourceId_1), resourceId: resourceId_1 });
20001
20041
  if (layerOptions.adapterOptions &&
@@ -20028,11 +20068,16 @@ function createRasterAdapter(_a) {
20028
20068
  return __awaiter(this, void 0, void 0, function () {
20029
20069
  var id;
20030
20070
  return __generator(this, function (_a) {
20031
- id = this.item && this.item.resource.parent.id;
20032
- if (defined(id)) {
20033
- return [2 /*return*/, [id]];
20071
+ if (this.item) {
20072
+ if (adapter === 'MVT') {
20073
+ return [2 /*return*/, [this.item.resource.id]];
20074
+ }
20075
+ id = this.item.resource.parent.id;
20076
+ if (defined(id)) {
20077
+ return [2 /*return*/, [id]];
20078
+ }
20034
20079
  }
20035
- return [2 /*return*/];
20080
+ return [2 /*return*/, []];
20036
20081
  });
20037
20082
  });
20038
20083
  };
@@ -21438,40 +21483,6 @@ function createWebMapAdapter(_a) {
21438
21483
  });
21439
21484
  }
21440
21485
 
21441
- var NgwResource = /** @class */ (function () {
21442
- function NgwResource() {
21443
- }
21444
- /** @deprecated use {@link NgwResource.getBounds} instead */
21445
- NgwResource.prototype.getExtent = function () {
21446
- return __awaiter(this, void 0, void 0, function () {
21447
- return __generator(this, function (_a) {
21448
- return [2 /*return*/, this.getBounds()];
21449
- });
21450
- });
21451
- };
21452
- NgwResource.prototype.getBounds = function (options) {
21453
- return __awaiter(this, void 0, void 0, function () {
21454
- var _a;
21455
- return __generator(this, function (_b) {
21456
- switch (_b.label) {
21457
- case 0:
21458
- if (this._extent) {
21459
- return [2 /*return*/, this._extent];
21460
- }
21461
- if (!this.item) return [3 /*break*/, 2];
21462
- _a = this;
21463
- return [4 /*yield*/, fetchNgwResourceExtent(this.item, this.connector, options)];
21464
- case 1:
21465
- _a._extent = _b.sent();
21466
- return [2 /*return*/, this._extent];
21467
- case 2: return [2 /*return*/];
21468
- }
21469
- });
21470
- });
21471
- };
21472
- return NgwResource;
21473
- }());
21474
-
21475
21486
  var alias = {
21476
21487
  tms: 'TILE',
21477
21488
  };
@@ -21699,7 +21710,7 @@ function createAdapterFromFirstStyle(_a) {
21699
21710
  }
21700
21711
  function createAsyncAdapter(options, webMap, connector) {
21701
21712
  return __awaiter(this, void 0, void 0, function () {
21702
- var adapter, item, adapterType, resourceId, resourceOptions, itemFromResOpt, cls, layerOptions, adapterOptions, parentItem, parentOptions, getClassAdapter, classAdapter;
21713
+ var adapter, item, adapterType, resourceId, resourceOptions, itemFromResOpt, cls, layerOptions, adapterOptions, type, adapterOptions_, parentItem, parentOptions, getClassAdapter, classAdapter;
21703
21714
  return __generator(this, function (_a) {
21704
21715
  switch (_a.label) {
21705
21716
  case 0:
@@ -21735,6 +21746,12 @@ function createAsyncAdapter(options, webMap, connector) {
21735
21746
  return [3 /*break*/, 11];
21736
21747
  case 5:
21737
21748
  if (!(cls === 'vector_layer')) return [3 /*break*/, 6];
21749
+ type = item.vector_layer &&
21750
+ vectorLayerGeomToPaintTypeAlias[item.vector_layer.geometry_type];
21751
+ adapterOptions_ = adapterOptions.layerOptions.adapterOptions || {};
21752
+ adapterOptions_.type = adapterOptions_.type || type;
21753
+ adapterOptions.layerOptions.adapterOptions = adapterOptions_;
21754
+ options.adapterOptions = adapterOptions;
21738
21755
  if (adapterType !== undefined && adapterType !== 'GEOJSON') {
21739
21756
  if (adapterType === 'MVT') {
21740
21757
  adapter = createRasterAdapter(adapterOptions);
@@ -22915,7 +22932,7 @@ var NgwMap = /** @class */ (function (_super) {
22915
22932
  };
22916
22933
  NgwMap.prototype._selectFromNgwRaster = function (ev) {
22917
22934
  return __awaiter(this, void 0, void 0, function () {
22918
- var promises, layers, getIdsPromise, getIds, ids, pixelRadius, center, zoom, radius, selectPromise;
22935
+ var promises, layers, _i, layers_1, l, layer, identFunc, getIdsPromise, getIds, ids, pixelRadius, center, zoom, radius, selectPromise;
22919
22936
  var _this = this;
22920
22937
  return __generator(this, function (_a) {
22921
22938
  switch (_a.label) {
@@ -22929,15 +22946,16 @@ var NgwMap = /** @class */ (function (_super) {
22929
22946
  }
22930
22947
  return 1;
22931
22948
  });
22932
- layers.forEach(function (l) {
22933
- var layer = l.layer;
22934
- var identFunc = typeof layer.getIdentificationIds === 'function'
22949
+ for (_i = 0, layers_1 = layers; _i < layers_1.length; _i++) {
22950
+ l = layers_1[_i];
22951
+ layer = l.layer;
22952
+ identFunc = typeof layer.getIdentificationIds === 'function'
22935
22953
  ? layer.getIdentificationIds
22936
22954
  : false;
22937
- if (identFunc && layer.options.selectable && _this.isLayerVisible(layer)) {
22955
+ if (identFunc && layer.options.selectable && this.isLayerVisible(layer)) {
22938
22956
  promises.push(identFunc.call(layer));
22939
22957
  }
22940
- });
22958
+ }
22941
22959
  getIdsPromise = Promise.all(promises);
22942
22960
  return [4 /*yield*/, getIdsPromise];
22943
22961
  case 1: