@nextgis/ngw-leaflet 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-leaflet; version: 1.13.6; author: NextGIS */
1
+ /** Bundle of @nextgis/ngw-leaflet; version: 1.14.0; 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;
@@ -15949,7 +15952,7 @@ function clearObject(obj) {
15949
15952
  var ID$2 = 0;
15950
15953
  var OPTIONS$1 = {
15951
15954
  minZoom: 0,
15952
- maxZoom: 20,
15955
+ maxZoom: 22,
15953
15956
  paint: {
15954
15957
  color: '#0000ff',
15955
15958
  opacity: 0.4,
@@ -19130,51 +19133,6 @@ var NgwConnector = /** @class */ (function () {
19130
19133
  return NgwConnector;
19131
19134
  }());
19132
19135
 
19133
- function createPopupContent(feature, item) {
19134
- // @ts-ignore
19135
- {
19136
- var element_1 = document.createElement('div');
19137
- if (item && item.feature_layer) {
19138
- item.feature_layer.fields.forEach(function (x) {
19139
- if (x.grid_visibility) {
19140
- var value = feature.properties && feature.properties[x.keyname];
19141
- if (value) {
19142
- var propElem = document.createElement('div');
19143
- element_1.appendChild(propElem);
19144
- propElem.innerHTML = "<span>".concat(x.display_name, "</span>: ").concat(value, "<span></span>");
19145
- }
19146
- }
19147
- });
19148
- }
19149
- else if (feature.properties) {
19150
- for (var p in feature.properties) {
19151
- var propElem = document.createElement('div');
19152
- element_1.appendChild(propElem);
19153
- propElem.innerHTML = "<span>".concat(p, "</span>: ").concat(feature.properties[p], "<span></span>");
19154
- }
19155
- }
19156
- return element_1;
19157
- }
19158
- }
19159
-
19160
- var filterOptionsKeys = [
19161
- 'fields',
19162
- 'intersects',
19163
- 'limit',
19164
- 'orderBy',
19165
- 'strategy',
19166
- ];
19167
- function getLayerFilterOptions(options) {
19168
- var filterOptions = {};
19169
- filterOptionsKeys.forEach(function (x) {
19170
- var opt = options[x];
19171
- if (opt !== undefined) {
19172
- filterOptions[x] = opt;
19173
- }
19174
- });
19175
- return filterOptions;
19176
- }
19177
-
19178
19136
  function getNgwWebmapExtent(webmap) {
19179
19137
  var bottom = webmap['extent_bottom'];
19180
19138
  var left = webmap['extent_left'];
@@ -19242,6 +19200,85 @@ function fetchNgwResourceExtent(item, connector, options) {
19242
19200
  }
19243
19201
  }
19244
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
+
19245
19282
  function resourceIdFromLayerOptions(options, connector) {
19246
19283
  return __awaiter(this, void 0, void 0, function () {
19247
19284
  var resource, item, keyname, resourceId, resourceItem;
@@ -19879,6 +19916,7 @@ function getImageAdapterOptions(_a) {
19879
19916
  };
19880
19917
  }
19881
19918
  function ngwApiToAdapterOptions(_a) {
19919
+ var _b;
19882
19920
  var options = _a.options, webMap = _a.webMap, baseUrl = _a.baseUrl;
19883
19921
  var adapter = options.adapter || 'IMAGE';
19884
19922
  var url;
@@ -19918,10 +19956,12 @@ function ngwApiToAdapterOptions(_a) {
19918
19956
  'resource=' +
19919
19957
  resourceId +
19920
19958
  '&simplification=' +
19921
- (options.simplification || 0);
19959
+ ((_b = options.simplification) !== null && _b !== void 0 ? _b : 6);
19922
19960
  // url = baseUrl + '/api/resource/' + options.resourceId + '/{z}/{x}/{y}.mvt';
19923
19961
  return {
19924
19962
  url: url,
19963
+ sourceLayer: 'ngw:' + resourceId,
19964
+ featureIdName: '$id',
19925
19965
  };
19926
19966
  }
19927
19967
  if (adapter === 'TERRAIN') {
@@ -19984,7 +20024,6 @@ function createRasterAdapter(_a) {
19984
20024
  return [2 /*return*/, /** @class */ (function (_super) {
19985
20025
  __extends(RasterAdapter, _super);
19986
20026
  function RasterAdapter(map, _options) {
19987
- var _a;
19988
20027
  var _this = _super.call(this, map, _options) || this;
19989
20028
  _this.map = map;
19990
20029
  // options = {};
@@ -19996,29 +20035,13 @@ function createRasterAdapter(_a) {
19996
20035
  baseUrl: connector.options.baseUrl || '',
19997
20036
  });
19998
20037
  if (opt) {
19999
- var layerAdapterOptions = __assign(__assign({}, opt), { setViewDelay: (_a = layerOptions.adapterOptions) === null || _a === void 0 ? void 0 : _a.setViewDelay, params: { resource: resourceId_1 },
20000
- // @deprecated
20001
- layers: String(resourceId_1), resourceId: resourceId_1 });
20038
+ var layerAdapterOptions = __assign(__assign(__assign({}, opt), layerOptions.adapterOptions), { params: { resource: resourceId_1 }, layers: opt.layers || String(resourceId_1), resourceId: resourceId_1 });
20002
20039
  if (layerOptions.adapterOptions &&
20003
20040
  defined(layerOptions.adapterOptions.setViewDelay)) {
20004
20041
  layerAdapterOptions.setViewDelay =
20005
20042
  layerOptions.adapterOptions.setViewDelay;
20006
20043
  }
20007
20044
  _this.options = __assign(__assign({}, _this.options), layerAdapterOptions);
20008
- // if (true) {
20009
- // Object.defineProperty(this.options, 'layers', {
20010
- // get: () => {
20011
- // console.warn('Do not use `layers` in ImageAdapterOptions');
20012
- // return String(resourceId);
20013
- // },
20014
- // });
20015
- // Object.defineProperty(this.options, 'resourceId', {
20016
- // get: () => {
20017
- // console.warn('Do not use `resourceId` in ImageAdapterOptions');
20018
- // return resourceId;
20019
- // },
20020
- // });
20021
- // }
20022
20045
  }
20023
20046
  return _this;
20024
20047
  }
@@ -20029,11 +20052,16 @@ function createRasterAdapter(_a) {
20029
20052
  return __awaiter(this, void 0, void 0, function () {
20030
20053
  var id;
20031
20054
  return __generator(this, function (_a) {
20032
- id = this.item && this.item.resource.parent.id;
20033
- if (defined(id)) {
20034
- return [2 /*return*/, [id]];
20055
+ if (this.item) {
20056
+ if (adapter === 'MVT') {
20057
+ return [2 /*return*/, [this.item.resource.id]];
20058
+ }
20059
+ id = this.item.resource.parent.id;
20060
+ if (defined(id)) {
20061
+ return [2 /*return*/, [id]];
20062
+ }
20035
20063
  }
20036
- return [2 /*return*/];
20064
+ return [2 /*return*/, []];
20037
20065
  });
20038
20066
  });
20039
20067
  };
@@ -21439,40 +21467,6 @@ function createWebMapAdapter(_a) {
21439
21467
  });
21440
21468
  }
21441
21469
 
21442
- var NgwResource = /** @class */ (function () {
21443
- function NgwResource() {
21444
- }
21445
- /** @deprecated use {@link NgwResource.getBounds} instead */
21446
- NgwResource.prototype.getExtent = function () {
21447
- return __awaiter(this, void 0, void 0, function () {
21448
- return __generator(this, function (_a) {
21449
- return [2 /*return*/, this.getBounds()];
21450
- });
21451
- });
21452
- };
21453
- NgwResource.prototype.getBounds = function (options) {
21454
- return __awaiter(this, void 0, void 0, function () {
21455
- var _a;
21456
- return __generator(this, function (_b) {
21457
- switch (_b.label) {
21458
- case 0:
21459
- if (this._extent) {
21460
- return [2 /*return*/, this._extent];
21461
- }
21462
- if (!this.item) return [3 /*break*/, 2];
21463
- _a = this;
21464
- return [4 /*yield*/, fetchNgwResourceExtent(this.item, this.connector, options)];
21465
- case 1:
21466
- _a._extent = _b.sent();
21467
- return [2 /*return*/, this._extent];
21468
- case 2: return [2 /*return*/];
21469
- }
21470
- });
21471
- });
21472
- };
21473
- return NgwResource;
21474
- }());
21475
-
21476
21470
  var alias = {
21477
21471
  tms: 'TILE',
21478
21472
  };
@@ -21700,7 +21694,7 @@ function createAdapterFromFirstStyle(_a) {
21700
21694
  }
21701
21695
  function createAsyncAdapter(options, webMap, connector) {
21702
21696
  return __awaiter(this, void 0, void 0, function () {
21703
- var adapter, item, adapterType, resourceId, resourceOptions, itemFromResOpt, cls, layerOptions, adapterOptions, parentItem, parentOptions, getClassAdapter, classAdapter;
21697
+ var adapter, item, adapterType, resourceId, resourceOptions, itemFromResOpt, cls, layerOptions, adapterOptions, type, adapterOptions_, parentItem, parentOptions, getClassAdapter, classAdapter;
21704
21698
  return __generator(this, function (_a) {
21705
21699
  switch (_a.label) {
21706
21700
  case 0:
@@ -21736,6 +21730,12 @@ function createAsyncAdapter(options, webMap, connector) {
21736
21730
  return [3 /*break*/, 11];
21737
21731
  case 5:
21738
21732
  if (!(cls === 'vector_layer')) return [3 /*break*/, 6];
21733
+ type = item.vector_layer &&
21734
+ vectorLayerGeomToPaintTypeAlias[item.vector_layer.geometry_type];
21735
+ adapterOptions_ = adapterOptions.layerOptions.adapterOptions || {};
21736
+ adapterOptions_.type = adapterOptions_.type || type;
21737
+ adapterOptions.layerOptions.adapterOptions = adapterOptions_;
21738
+ options.adapterOptions = adapterOptions;
21739
21739
  if (adapterType !== undefined && adapterType !== 'GEOJSON') {
21740
21740
  if (adapterType === 'MVT') {
21741
21741
  adapter = createRasterAdapter(adapterOptions);
@@ -22712,13 +22712,14 @@ var NgwMap = /** @class */ (function (_super) {
22712
22712
  var _this = this;
22713
22713
  if (!this.$$selectFromNgwRaster) {
22714
22714
  this.$$selectFromNgwRaster = function (ev) {
22715
- var count = _this.emitter.listenerCount('ngw:select');
22715
+ var count = _this._getSelectListenersCount();
22716
22716
  if (count) {
22717
22717
  _this._selectFromNgwRaster(ev);
22718
22718
  }
22719
22719
  };
22720
22720
  this.$$selectFromNgwVector = function (ev) {
22721
- if (_this.emitter.listenerCount('ngw:select')) {
22721
+ var count = _this._getSelectListenersCount();
22722
+ if (count) {
22722
22723
  _this._selectFromNgwVector(ev);
22723
22724
  }
22724
22725
  };
@@ -22729,8 +22730,10 @@ var NgwMap = /** @class */ (function (_super) {
22729
22730
  NgwMap.prototype.disableSelection = function () {
22730
22731
  if (this.$$selectFromNgwRaster) {
22731
22732
  this.emitter.removeListener('click', this.$$selectFromNgwRaster);
22732
- this.emitter.removeListener('click', this._selectFromNgwVector);
22733
22733
  this.$$selectFromNgwRaster = undefined;
22734
+ }
22735
+ if (this.$$selectFromNgwVector) {
22736
+ this.emitter.removeListener('layer:click', this.$$selectFromNgwVector);
22734
22737
  this.$$selectFromNgwVector = undefined;
22735
22738
  }
22736
22739
  };
@@ -22886,7 +22889,11 @@ var NgwMap = /** @class */ (function (_super) {
22886
22889
  NgwMap.prototype._selectFromNgwVector = function (ev) {
22887
22890
  var _a;
22888
22891
  var layer = ev.layer;
22889
- // item property means layer is NgwResource
22892
+ var selectable = layer.options.selectable && this.isLayerVisible(layer);
22893
+ if (!selectable) {
22894
+ return undefined;
22895
+ }
22896
+ // Item property means layer is NgwResource
22890
22897
  var id = layer.item && layer.item.resource.id;
22891
22898
  var feature = ev.feature;
22892
22899
  if (id !== undefined && feature) {
@@ -22916,10 +22923,10 @@ var NgwMap = /** @class */ (function (_super) {
22916
22923
  };
22917
22924
  NgwMap.prototype._selectFromNgwRaster = function (ev) {
22918
22925
  return __awaiter(this, void 0, void 0, function () {
22919
- var promises, layers, getIdsPromise, getIds, ids, pixelRadius, center, zoom, radius, selectPromise;
22926
+ var promises, layers, _i, layers_1, l, layer, identFunc, getIdsPromise, getIds, ids, _a, getIds_1, x, pixelRadius, center, zoom, radius, selectPromise;
22920
22927
  var _this = this;
22921
- return __generator(this, function (_a) {
22922
- switch (_a.label) {
22928
+ return __generator(this, function (_b) {
22929
+ switch (_b.label) {
22923
22930
  case 0:
22924
22931
  this._emitStatusEvent('ngw:preselect');
22925
22932
  promises = [];
@@ -22930,25 +22937,27 @@ var NgwMap = /** @class */ (function (_super) {
22930
22937
  }
22931
22938
  return 1;
22932
22939
  });
22933
- layers.forEach(function (l) {
22934
- var layer = l.layer;
22935
- var identFunc = typeof layer.getIdentificationIds === 'function'
22940
+ for (_i = 0, layers_1 = layers; _i < layers_1.length; _i++) {
22941
+ l = layers_1[_i];
22942
+ layer = l.layer;
22943
+ identFunc = typeof layer.getIdentificationIds === 'function'
22936
22944
  ? layer.getIdentificationIds
22937
22945
  : false;
22938
- if (identFunc && layer.options.selectable && _this.isLayerVisible(layer)) {
22946
+ if (identFunc && layer.options.selectable && this.isLayerVisible(layer)) {
22939
22947
  promises.push(identFunc.call(layer));
22940
22948
  }
22941
- });
22949
+ }
22942
22950
  getIdsPromise = Promise.all(promises);
22943
22951
  return [4 /*yield*/, getIdsPromise];
22944
22952
  case 1:
22945
- getIds = _a.sent();
22953
+ getIds = _b.sent();
22946
22954
  ids = [];
22947
- getIds.forEach(function (x) {
22955
+ for (_a = 0, getIds_1 = getIds; _a < getIds_1.length; _a++) {
22956
+ x = getIds_1[_a];
22948
22957
  if (x) {
22949
- x.forEach(function (y) { return ids.push(y); });
22958
+ ids.push.apply(ids, x);
22950
22959
  }
22951
- });
22960
+ }
22952
22961
  if (!ids.length) {
22953
22962
  this._emitStatusEvent('ngw:select', null);
22954
22963
  return [2 /*return*/];
@@ -22988,6 +22997,9 @@ var NgwMap = /** @class */ (function (_super) {
22988
22997
  };
22989
22998
  return __assign(__assign({}, identify), { getIdentifyItems: getIdentifyItems_ });
22990
22999
  };
23000
+ NgwMap.prototype._getSelectListenersCount = function () {
23001
+ return this.emitter.listenerCount('ngw:select');
23002
+ };
22991
23003
  NgwMap.prototype._whiteLabel = function () {
22992
23004
  return __awaiter(this, void 0, void 0, function () {
22993
23005
  var container, logo;
@@ -23975,7 +23987,6 @@ var ImageLayer = /** @class */ (function (_super) {
23975
23987
  opacity: 1,
23976
23988
  isBack: false,
23977
23989
  minZoom: 0,
23978
- maxZoom: 18,
23979
23990
  pane: 'tilePane',
23980
23991
  headers: null,
23981
23992
  viewPortBuffer: 0,
@@ -24280,8 +24291,7 @@ var WmsLayerBase = /** @class */ (function (_super) {
24280
24291
  }
24281
24292
  return WmsLayerBase;
24282
24293
  }(leafletSrc.exports.TileLayer.WMS));
24283
- var WmsLayer = makeRemote(WmsLayerBase);
24284
- // applyMixins(WmsLayer, [RemoteTileLayer]);
24294
+ var WmsLayer = makeRemote(WmsLayerBase);
24285
24295
 
24286
24296
  var WmsAdapter = /** @class */ (function (_super) {
24287
24297
  __extends(WmsAdapter, _super);