@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
  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.6; author: NextGIS */
1
+ /** Bundle of @nextgis/ngw-leaflet; version: 1.14.0; 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;
@@ -15952,7 +15955,7 @@ var NgwLeaflet = (function () {
15952
15955
  var ID$2 = 0;
15953
15956
  var OPTIONS$1 = {
15954
15957
  minZoom: 0,
15955
- maxZoom: 20,
15958
+ maxZoom: 22,
15956
15959
  paint: {
15957
15960
  color: '#0000ff',
15958
15961
  opacity: 0.4,
@@ -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,10 +19959,12 @@ 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 : 6);
19925
19963
  // url = baseUrl + '/api/resource/' + options.resourceId + '/{z}/{x}/{y}.mvt';
19926
19964
  return {
19927
19965
  url: url,
19966
+ sourceLayer: 'ngw:' + resourceId,
19967
+ featureIdName: '$id',
19928
19968
  };
19929
19969
  }
19930
19970
  if (adapter === 'TERRAIN') {
@@ -19987,7 +20027,6 @@ var NgwLeaflet = (function () {
19987
20027
  return [2 /*return*/, /** @class */ (function (_super) {
19988
20028
  __extends(RasterAdapter, _super);
19989
20029
  function RasterAdapter(map, _options) {
19990
- var _a;
19991
20030
  var _this = _super.call(this, map, _options) || this;
19992
20031
  _this.map = map;
19993
20032
  // options = {};
@@ -19999,29 +20038,13 @@ var NgwLeaflet = (function () {
19999
20038
  baseUrl: connector.options.baseUrl || '',
20000
20039
  });
20001
20040
  if (opt) {
20002
- var layerAdapterOptions = __assign(__assign({}, opt), { setViewDelay: (_a = layerOptions.adapterOptions) === null || _a === void 0 ? void 0 : _a.setViewDelay, params: { resource: resourceId_1 },
20003
- // @deprecated
20004
- layers: String(resourceId_1), resourceId: resourceId_1 });
20041
+ var layerAdapterOptions = __assign(__assign(__assign({}, opt), layerOptions.adapterOptions), { params: { resource: resourceId_1 }, layers: opt.layers || String(resourceId_1), resourceId: resourceId_1 });
20005
20042
  if (layerOptions.adapterOptions &&
20006
20043
  defined(layerOptions.adapterOptions.setViewDelay)) {
20007
20044
  layerAdapterOptions.setViewDelay =
20008
20045
  layerOptions.adapterOptions.setViewDelay;
20009
20046
  }
20010
20047
  _this.options = __assign(__assign({}, _this.options), layerAdapterOptions);
20011
- // if (true) {
20012
- // Object.defineProperty(this.options, 'layers', {
20013
- // get: () => {
20014
- // console.warn('Do not use `layers` in ImageAdapterOptions');
20015
- // return String(resourceId);
20016
- // },
20017
- // });
20018
- // Object.defineProperty(this.options, 'resourceId', {
20019
- // get: () => {
20020
- // console.warn('Do not use `resourceId` in ImageAdapterOptions');
20021
- // return resourceId;
20022
- // },
20023
- // });
20024
- // }
20025
20048
  }
20026
20049
  return _this;
20027
20050
  }
@@ -20032,11 +20055,16 @@ var NgwLeaflet = (function () {
20032
20055
  return __awaiter(this, void 0, void 0, function () {
20033
20056
  var id;
20034
20057
  return __generator(this, function (_a) {
20035
- id = this.item && this.item.resource.parent.id;
20036
- if (defined(id)) {
20037
- return [2 /*return*/, [id]];
20058
+ if (this.item) {
20059
+ if (adapter === 'MVT') {
20060
+ return [2 /*return*/, [this.item.resource.id]];
20061
+ }
20062
+ id = this.item.resource.parent.id;
20063
+ if (defined(id)) {
20064
+ return [2 /*return*/, [id]];
20065
+ }
20038
20066
  }
20039
- return [2 /*return*/];
20067
+ return [2 /*return*/, []];
20040
20068
  });
20041
20069
  });
20042
20070
  };
@@ -21442,40 +21470,6 @@ var NgwLeaflet = (function () {
21442
21470
  });
21443
21471
  }
21444
21472
 
21445
- var NgwResource = /** @class */ (function () {
21446
- function NgwResource() {
21447
- }
21448
- /** @deprecated use {@link NgwResource.getBounds} instead */
21449
- NgwResource.prototype.getExtent = function () {
21450
- return __awaiter(this, void 0, void 0, function () {
21451
- return __generator(this, function (_a) {
21452
- return [2 /*return*/, this.getBounds()];
21453
- });
21454
- });
21455
- };
21456
- NgwResource.prototype.getBounds = function (options) {
21457
- return __awaiter(this, void 0, void 0, function () {
21458
- var _a;
21459
- return __generator(this, function (_b) {
21460
- switch (_b.label) {
21461
- case 0:
21462
- if (this._extent) {
21463
- return [2 /*return*/, this._extent];
21464
- }
21465
- if (!this.item) return [3 /*break*/, 2];
21466
- _a = this;
21467
- return [4 /*yield*/, fetchNgwResourceExtent(this.item, this.connector, options)];
21468
- case 1:
21469
- _a._extent = _b.sent();
21470
- return [2 /*return*/, this._extent];
21471
- case 2: return [2 /*return*/];
21472
- }
21473
- });
21474
- });
21475
- };
21476
- return NgwResource;
21477
- }());
21478
-
21479
21473
  var alias = {
21480
21474
  tms: 'TILE',
21481
21475
  };
@@ -21703,7 +21697,7 @@ var NgwLeaflet = (function () {
21703
21697
  }
21704
21698
  function createAsyncAdapter(options, webMap, connector) {
21705
21699
  return __awaiter(this, void 0, void 0, function () {
21706
- var adapter, item, adapterType, resourceId, resourceOptions, itemFromResOpt, cls, layerOptions, adapterOptions, parentItem, parentOptions, getClassAdapter, classAdapter;
21700
+ var adapter, item, adapterType, resourceId, resourceOptions, itemFromResOpt, cls, layerOptions, adapterOptions, type, adapterOptions_, parentItem, parentOptions, getClassAdapter, classAdapter;
21707
21701
  return __generator(this, function (_a) {
21708
21702
  switch (_a.label) {
21709
21703
  case 0:
@@ -21739,6 +21733,12 @@ var NgwLeaflet = (function () {
21739
21733
  return [3 /*break*/, 11];
21740
21734
  case 5:
21741
21735
  if (!(cls === 'vector_layer')) return [3 /*break*/, 6];
21736
+ type = item.vector_layer &&
21737
+ vectorLayerGeomToPaintTypeAlias[item.vector_layer.geometry_type];
21738
+ adapterOptions_ = adapterOptions.layerOptions.adapterOptions || {};
21739
+ adapterOptions_.type = adapterOptions_.type || type;
21740
+ adapterOptions.layerOptions.adapterOptions = adapterOptions_;
21741
+ options.adapterOptions = adapterOptions;
21742
21742
  if (adapterType !== undefined && adapterType !== 'GEOJSON') {
21743
21743
  if (adapterType === 'MVT') {
21744
21744
  adapter = createRasterAdapter(adapterOptions);
@@ -22715,13 +22715,14 @@ var NgwLeaflet = (function () {
22715
22715
  var _this = this;
22716
22716
  if (!this.$$selectFromNgwRaster) {
22717
22717
  this.$$selectFromNgwRaster = function (ev) {
22718
- var count = _this.emitter.listenerCount('ngw:select');
22718
+ var count = _this._getSelectListenersCount();
22719
22719
  if (count) {
22720
22720
  _this._selectFromNgwRaster(ev);
22721
22721
  }
22722
22722
  };
22723
22723
  this.$$selectFromNgwVector = function (ev) {
22724
- if (_this.emitter.listenerCount('ngw:select')) {
22724
+ var count = _this._getSelectListenersCount();
22725
+ if (count) {
22725
22726
  _this._selectFromNgwVector(ev);
22726
22727
  }
22727
22728
  };
@@ -22732,8 +22733,10 @@ var NgwLeaflet = (function () {
22732
22733
  NgwMap.prototype.disableSelection = function () {
22733
22734
  if (this.$$selectFromNgwRaster) {
22734
22735
  this.emitter.removeListener('click', this.$$selectFromNgwRaster);
22735
- this.emitter.removeListener('click', this._selectFromNgwVector);
22736
22736
  this.$$selectFromNgwRaster = undefined;
22737
+ }
22738
+ if (this.$$selectFromNgwVector) {
22739
+ this.emitter.removeListener('layer:click', this.$$selectFromNgwVector);
22737
22740
  this.$$selectFromNgwVector = undefined;
22738
22741
  }
22739
22742
  };
@@ -22889,7 +22892,11 @@ var NgwLeaflet = (function () {
22889
22892
  NgwMap.prototype._selectFromNgwVector = function (ev) {
22890
22893
  var _a;
22891
22894
  var layer = ev.layer;
22892
- // item property means layer is NgwResource
22895
+ var selectable = layer.options.selectable && this.isLayerVisible(layer);
22896
+ if (!selectable) {
22897
+ return undefined;
22898
+ }
22899
+ // Item property means layer is NgwResource
22893
22900
  var id = layer.item && layer.item.resource.id;
22894
22901
  var feature = ev.feature;
22895
22902
  if (id !== undefined && feature) {
@@ -22919,10 +22926,10 @@ var NgwLeaflet = (function () {
22919
22926
  };
22920
22927
  NgwMap.prototype._selectFromNgwRaster = function (ev) {
22921
22928
  return __awaiter(this, void 0, void 0, function () {
22922
- var promises, layers, getIdsPromise, getIds, ids, pixelRadius, center, zoom, radius, selectPromise;
22929
+ var promises, layers, _i, layers_1, l, layer, identFunc, getIdsPromise, getIds, ids, _a, getIds_1, x, pixelRadius, center, zoom, radius, selectPromise;
22923
22930
  var _this = this;
22924
- return __generator(this, function (_a) {
22925
- switch (_a.label) {
22931
+ return __generator(this, function (_b) {
22932
+ switch (_b.label) {
22926
22933
  case 0:
22927
22934
  this._emitStatusEvent('ngw:preselect');
22928
22935
  promises = [];
@@ -22933,25 +22940,27 @@ var NgwLeaflet = (function () {
22933
22940
  }
22934
22941
  return 1;
22935
22942
  });
22936
- layers.forEach(function (l) {
22937
- var layer = l.layer;
22938
- var identFunc = typeof layer.getIdentificationIds === 'function'
22943
+ for (_i = 0, layers_1 = layers; _i < layers_1.length; _i++) {
22944
+ l = layers_1[_i];
22945
+ layer = l.layer;
22946
+ identFunc = typeof layer.getIdentificationIds === 'function'
22939
22947
  ? layer.getIdentificationIds
22940
22948
  : false;
22941
- if (identFunc && layer.options.selectable && _this.isLayerVisible(layer)) {
22949
+ if (identFunc && layer.options.selectable && this.isLayerVisible(layer)) {
22942
22950
  promises.push(identFunc.call(layer));
22943
22951
  }
22944
- });
22952
+ }
22945
22953
  getIdsPromise = Promise.all(promises);
22946
22954
  return [4 /*yield*/, getIdsPromise];
22947
22955
  case 1:
22948
- getIds = _a.sent();
22956
+ getIds = _b.sent();
22949
22957
  ids = [];
22950
- getIds.forEach(function (x) {
22958
+ for (_a = 0, getIds_1 = getIds; _a < getIds_1.length; _a++) {
22959
+ x = getIds_1[_a];
22951
22960
  if (x) {
22952
- x.forEach(function (y) { return ids.push(y); });
22961
+ ids.push.apply(ids, x);
22953
22962
  }
22954
- });
22963
+ }
22955
22964
  if (!ids.length) {
22956
22965
  this._emitStatusEvent('ngw:select', null);
22957
22966
  return [2 /*return*/];
@@ -22991,6 +23000,9 @@ var NgwLeaflet = (function () {
22991
23000
  };
22992
23001
  return __assign(__assign({}, identify), { getIdentifyItems: getIdentifyItems_ });
22993
23002
  };
23003
+ NgwMap.prototype._getSelectListenersCount = function () {
23004
+ return this.emitter.listenerCount('ngw:select');
23005
+ };
22994
23006
  NgwMap.prototype._whiteLabel = function () {
22995
23007
  return __awaiter(this, void 0, void 0, function () {
22996
23008
  var container, logo;
@@ -23978,7 +23990,6 @@ var NgwLeaflet = (function () {
23978
23990
  opacity: 1,
23979
23991
  isBack: false,
23980
23992
  minZoom: 0,
23981
- maxZoom: 18,
23982
23993
  pane: 'tilePane',
23983
23994
  headers: null,
23984
23995
  viewPortBuffer: 0,
@@ -24283,8 +24294,7 @@ var NgwLeaflet = (function () {
24283
24294
  }
24284
24295
  return WmsLayerBase;
24285
24296
  }(leafletSrc.exports.TileLayer.WMS));
24286
- var WmsLayer = makeRemote(WmsLayerBase);
24287
- // applyMixins(WmsLayer, [RemoteTileLayer]);
24297
+ var WmsLayer = makeRemote(WmsLayerBase);
24288
24298
 
24289
24299
  var WmsAdapter = /** @class */ (function (_super) {
24290
24300
  __extends(WmsAdapter, _super);