@nextgis/ngw-leaflet 1.13.7 → 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.7; author: NextGIS */
1
+ /** Bundle of @nextgis/ngw-leaflet; version: 1.13.8; author: NextGIS */
2
2
  import 'leaflet/dist/leaflet.css';
3
3
  import { Icon } from 'leaflet';
4
4
  import { NgwMap } from '@nextgis/ngw-map';
@@ -1,4 +1,4 @@
1
- /** Bundle of @nextgis/ngw-leaflet; version: 1.13.7; author: NextGIS */
1
+ /** Bundle of @nextgis/ngw-leaflet; version: 1.13.8; author: NextGIS */
2
2
  var NgwLeaflet = (function () {
3
3
  'use strict';
4
4
 
@@ -15597,16 +15597,17 @@ var NgwLeaflet = (function () {
15597
15597
  function createPropertiesPaint(propertiesPaint) {
15598
15598
  var mask = {};
15599
15599
  var paintsFilters = [];
15600
- propertiesPaint.forEach(function (x) {
15601
- if (x) {
15602
- if (Array.isArray(x)) {
15603
- paintsFilters.push(x);
15600
+ for (var _i = 0, propertiesPaint_1 = propertiesPaint; _i < propertiesPaint_1.length; _i++) {
15601
+ var p = propertiesPaint_1[_i];
15602
+ if (p) {
15603
+ if (Array.isArray(p)) {
15604
+ paintsFilters.push(p);
15604
15605
  }
15605
15606
  else {
15606
- mask = x;
15607
+ mask = p;
15607
15608
  }
15608
15609
  }
15609
- });
15610
+ }
15610
15611
  return function (feature) {
15611
15612
  var paint = paintsFilters.find(function (x) { return featureFilter(feature, x[0]); });
15612
15613
  if (paint) {
@@ -15646,9 +15647,11 @@ var NgwLeaflet = (function () {
15646
15647
  else {
15647
15648
  var expressionCallback_1 = createExpressionCallback(paint);
15648
15649
  if (expressionCallback_1) {
15649
- return function (feature) {
15650
+ var expressionPaintCb = function (feature) {
15650
15651
  return preparePaint(expressionCallback_1(feature), defaultPaint, getPaintFunctions);
15651
15652
  };
15653
+ expressionPaintCb.paint = paint;
15654
+ return expressionPaintCb;
15652
15655
  }
15653
15656
  newPaint = __assign(__assign({}, newPaint), paint);
15654
15657
  newPaint.fill = newPaint.fill !== undefined ? newPaint.fill : true;
@@ -19133,51 +19136,6 @@ var NgwLeaflet = (function () {
19133
19136
  return NgwConnector;
19134
19137
  }());
19135
19138
 
19136
- function createPopupContent(feature, item) {
19137
- // @ts-ignore
19138
- {
19139
- var element_1 = document.createElement('div');
19140
- if (item && item.feature_layer) {
19141
- item.feature_layer.fields.forEach(function (x) {
19142
- if (x.grid_visibility) {
19143
- var value = feature.properties && feature.properties[x.keyname];
19144
- if (value) {
19145
- var propElem = document.createElement('div');
19146
- element_1.appendChild(propElem);
19147
- propElem.innerHTML = "<span>".concat(x.display_name, "</span>: ").concat(value, "<span></span>");
19148
- }
19149
- }
19150
- });
19151
- }
19152
- else if (feature.properties) {
19153
- for (var p in feature.properties) {
19154
- var propElem = document.createElement('div');
19155
- element_1.appendChild(propElem);
19156
- propElem.innerHTML = "<span>".concat(p, "</span>: ").concat(feature.properties[p], "<span></span>");
19157
- }
19158
- }
19159
- return element_1;
19160
- }
19161
- }
19162
-
19163
- var filterOptionsKeys = [
19164
- 'fields',
19165
- 'intersects',
19166
- 'limit',
19167
- 'orderBy',
19168
- 'strategy',
19169
- ];
19170
- function getLayerFilterOptions(options) {
19171
- var filterOptions = {};
19172
- filterOptionsKeys.forEach(function (x) {
19173
- var opt = options[x];
19174
- if (opt !== undefined) {
19175
- filterOptions[x] = opt;
19176
- }
19177
- });
19178
- return filterOptions;
19179
- }
19180
-
19181
19139
  function getNgwWebmapExtent(webmap) {
19182
19140
  var bottom = webmap['extent_bottom'];
19183
19141
  var left = webmap['extent_left'];
@@ -19245,6 +19203,85 @@ var NgwLeaflet = (function () {
19245
19203
  }
19246
19204
  }
19247
19205
 
19206
+ var NgwResource = /** @class */ (function () {
19207
+ function NgwResource() {
19208
+ }
19209
+ /** @deprecated use {@link NgwResource.getBounds} instead */
19210
+ NgwResource.prototype.getExtent = function () {
19211
+ return __awaiter(this, void 0, void 0, function () {
19212
+ return __generator(this, function (_a) {
19213
+ return [2 /*return*/, this.getBounds()];
19214
+ });
19215
+ });
19216
+ };
19217
+ NgwResource.prototype.getBounds = function (options) {
19218
+ return __awaiter(this, void 0, void 0, function () {
19219
+ var _a;
19220
+ return __generator(this, function (_b) {
19221
+ switch (_b.label) {
19222
+ case 0:
19223
+ if (this._extent) {
19224
+ return [2 /*return*/, this._extent];
19225
+ }
19226
+ if (!this.item) return [3 /*break*/, 2];
19227
+ _a = this;
19228
+ return [4 /*yield*/, fetchNgwResourceExtent(this.item, this.connector, options)];
19229
+ case 1:
19230
+ _a._extent = _b.sent();
19231
+ return [2 /*return*/, this._extent];
19232
+ case 2: return [2 /*return*/];
19233
+ }
19234
+ });
19235
+ });
19236
+ };
19237
+ return NgwResource;
19238
+ }());
19239
+
19240
+ function createPopupContent(feature, item) {
19241
+ // @ts-ignore
19242
+ {
19243
+ var element_1 = document.createElement('div');
19244
+ if (item && item.feature_layer) {
19245
+ item.feature_layer.fields.forEach(function (x) {
19246
+ if (x.grid_visibility) {
19247
+ var value = feature.properties && feature.properties[x.keyname];
19248
+ if (value) {
19249
+ var propElem = document.createElement('div');
19250
+ element_1.appendChild(propElem);
19251
+ propElem.innerHTML = "<span>".concat(x.display_name, "</span>: ").concat(value, "<span></span>");
19252
+ }
19253
+ }
19254
+ });
19255
+ }
19256
+ else if (feature.properties) {
19257
+ for (var p in feature.properties) {
19258
+ var propElem = document.createElement('div');
19259
+ element_1.appendChild(propElem);
19260
+ propElem.innerHTML = "<span>".concat(p, "</span>: ").concat(feature.properties[p], "<span></span>");
19261
+ }
19262
+ }
19263
+ return element_1;
19264
+ }
19265
+ }
19266
+
19267
+ var filterOptionsKeys = [
19268
+ 'fields',
19269
+ 'intersects',
19270
+ 'limit',
19271
+ 'orderBy',
19272
+ 'strategy',
19273
+ ];
19274
+ function getLayerFilterOptions(options) {
19275
+ var filterOptions = {};
19276
+ filterOptionsKeys.forEach(function (x) {
19277
+ var opt = options[x];
19278
+ if (opt !== undefined) {
19279
+ filterOptions[x] = opt;
19280
+ }
19281
+ });
19282
+ return filterOptions;
19283
+ }
19284
+
19248
19285
  function resourceIdFromLayerOptions(options, connector) {
19249
19286
  return __awaiter(this, void 0, void 0, function () {
19250
19287
  var resource, item, keyname, resourceId, resourceItem;
@@ -19882,6 +19919,7 @@ var NgwLeaflet = (function () {
19882
19919
  };
19883
19920
  }
19884
19921
  function ngwApiToAdapterOptions(_a) {
19922
+ var _b;
19885
19923
  var options = _a.options, webMap = _a.webMap, baseUrl = _a.baseUrl;
19886
19924
  var adapter = options.adapter || 'IMAGE';
19887
19925
  var url;
@@ -19921,7 +19959,7 @@ var NgwLeaflet = (function () {
19921
19959
  'resource=' +
19922
19960
  resourceId +
19923
19961
  '&simplification=' +
19924
- (options.simplification || 0);
19962
+ ((_b = options.simplification) !== null && _b !== void 0 ? _b : 8);
19925
19963
  // url = baseUrl + '/api/resource/' + options.resourceId + '/{z}/{x}/{y}.mvt';
19926
19964
  return {
19927
19965
  url: url,
@@ -19989,7 +20027,6 @@ var NgwLeaflet = (function () {
19989
20027
  return [2 /*return*/, /** @class */ (function (_super) {
19990
20028
  __extends(RasterAdapter, _super);
19991
20029
  function RasterAdapter(map, _options) {
19992
- var _a;
19993
20030
  var _this = _super.call(this, map, _options) || this;
19994
20031
  _this.map = map;
19995
20032
  // options = {};
@@ -20001,7 +20038,7 @@ var NgwLeaflet = (function () {
20001
20038
  baseUrl: connector.options.baseUrl || '',
20002
20039
  });
20003
20040
  if (opt) {
20004
- var layerAdapterOptions = __assign(__assign({}, opt), { setViewDelay: (_a = layerOptions.adapterOptions) === null || _a === void 0 ? void 0 : _a.setViewDelay, params: { resource: resourceId_1 },
20041
+ var layerAdapterOptions = __assign(__assign(__assign({}, opt), layerOptions.adapterOptions), { params: { resource: resourceId_1 },
20005
20042
  // @deprecated
20006
20043
  layers: String(resourceId_1), resourceId: resourceId_1 });
20007
20044
  if (layerOptions.adapterOptions &&
@@ -20034,11 +20071,16 @@ var NgwLeaflet = (function () {
20034
20071
  return __awaiter(this, void 0, void 0, function () {
20035
20072
  var id;
20036
20073
  return __generator(this, function (_a) {
20037
- id = this.item && this.item.resource.parent.id;
20038
- if (defined(id)) {
20039
- return [2 /*return*/, [id]];
20074
+ if (this.item) {
20075
+ if (adapter === 'MVT') {
20076
+ return [2 /*return*/, [this.item.resource.id]];
20077
+ }
20078
+ id = this.item.resource.parent.id;
20079
+ if (defined(id)) {
20080
+ return [2 /*return*/, [id]];
20081
+ }
20040
20082
  }
20041
- return [2 /*return*/];
20083
+ return [2 /*return*/, []];
20042
20084
  });
20043
20085
  });
20044
20086
  };
@@ -21444,40 +21486,6 @@ var NgwLeaflet = (function () {
21444
21486
  });
21445
21487
  }
21446
21488
 
21447
- var NgwResource = /** @class */ (function () {
21448
- function NgwResource() {
21449
- }
21450
- /** @deprecated use {@link NgwResource.getBounds} instead */
21451
- NgwResource.prototype.getExtent = function () {
21452
- return __awaiter(this, void 0, void 0, function () {
21453
- return __generator(this, function (_a) {
21454
- return [2 /*return*/, this.getBounds()];
21455
- });
21456
- });
21457
- };
21458
- NgwResource.prototype.getBounds = function (options) {
21459
- return __awaiter(this, void 0, void 0, function () {
21460
- var _a;
21461
- return __generator(this, function (_b) {
21462
- switch (_b.label) {
21463
- case 0:
21464
- if (this._extent) {
21465
- return [2 /*return*/, this._extent];
21466
- }
21467
- if (!this.item) return [3 /*break*/, 2];
21468
- _a = this;
21469
- return [4 /*yield*/, fetchNgwResourceExtent(this.item, this.connector, options)];
21470
- case 1:
21471
- _a._extent = _b.sent();
21472
- return [2 /*return*/, this._extent];
21473
- case 2: return [2 /*return*/];
21474
- }
21475
- });
21476
- });
21477
- };
21478
- return NgwResource;
21479
- }());
21480
-
21481
21489
  var alias = {
21482
21490
  tms: 'TILE',
21483
21491
  };
@@ -21705,7 +21713,7 @@ var NgwLeaflet = (function () {
21705
21713
  }
21706
21714
  function createAsyncAdapter(options, webMap, connector) {
21707
21715
  return __awaiter(this, void 0, void 0, function () {
21708
- var adapter, item, adapterType, resourceId, resourceOptions, itemFromResOpt, cls, layerOptions, adapterOptions, parentItem, parentOptions, getClassAdapter, classAdapter;
21716
+ var adapter, item, adapterType, resourceId, resourceOptions, itemFromResOpt, cls, layerOptions, adapterOptions, type, adapterOptions_, parentItem, parentOptions, getClassAdapter, classAdapter;
21709
21717
  return __generator(this, function (_a) {
21710
21718
  switch (_a.label) {
21711
21719
  case 0:
@@ -21741,6 +21749,12 @@ var NgwLeaflet = (function () {
21741
21749
  return [3 /*break*/, 11];
21742
21750
  case 5:
21743
21751
  if (!(cls === 'vector_layer')) return [3 /*break*/, 6];
21752
+ type = item.vector_layer &&
21753
+ vectorLayerGeomToPaintTypeAlias[item.vector_layer.geometry_type];
21754
+ adapterOptions_ = adapterOptions.layerOptions.adapterOptions || {};
21755
+ adapterOptions_.type = adapterOptions_.type || type;
21756
+ adapterOptions.layerOptions.adapterOptions = adapterOptions_;
21757
+ options.adapterOptions = adapterOptions;
21744
21758
  if (adapterType !== undefined && adapterType !== 'GEOJSON') {
21745
21759
  if (adapterType === 'MVT') {
21746
21760
  adapter = createRasterAdapter(adapterOptions);
@@ -22921,7 +22935,7 @@ var NgwLeaflet = (function () {
22921
22935
  };
22922
22936
  NgwMap.prototype._selectFromNgwRaster = function (ev) {
22923
22937
  return __awaiter(this, void 0, void 0, function () {
22924
- var promises, layers, getIdsPromise, getIds, ids, pixelRadius, center, zoom, radius, selectPromise;
22938
+ var promises, layers, _i, layers_1, l, layer, identFunc, getIdsPromise, getIds, ids, pixelRadius, center, zoom, radius, selectPromise;
22925
22939
  var _this = this;
22926
22940
  return __generator(this, function (_a) {
22927
22941
  switch (_a.label) {
@@ -22935,15 +22949,16 @@ var NgwLeaflet = (function () {
22935
22949
  }
22936
22950
  return 1;
22937
22951
  });
22938
- layers.forEach(function (l) {
22939
- var layer = l.layer;
22940
- var identFunc = typeof layer.getIdentificationIds === 'function'
22952
+ for (_i = 0, layers_1 = layers; _i < layers_1.length; _i++) {
22953
+ l = layers_1[_i];
22954
+ layer = l.layer;
22955
+ identFunc = typeof layer.getIdentificationIds === 'function'
22941
22956
  ? layer.getIdentificationIds
22942
22957
  : false;
22943
- if (identFunc && layer.options.selectable && _this.isLayerVisible(layer)) {
22958
+ if (identFunc && layer.options.selectable && this.isLayerVisible(layer)) {
22944
22959
  promises.push(identFunc.call(layer));
22945
22960
  }
22946
- });
22961
+ }
22947
22962
  getIdsPromise = Promise.all(promises);
22948
22963
  return [4 /*yield*/, getIdsPromise];
22949
22964
  case 1: