@nextgis/ngw-leaflet 1.13.0 → 1.13.2

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.0; author: NextGIS */
1
+ /** Bundle of @nextgis/ngw-leaflet; version: 1.13.2; 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.0; author: NextGIS */
1
+ /** Bundle of @nextgis/ngw-leaflet; version: 1.13.2; author: NextGIS */
2
2
  var NgwLeaflet = (function () {
3
3
  'use strict';
4
4
 
@@ -18119,31 +18119,31 @@ var NgwLeaflet = (function () {
18119
18119
  /**
18120
18120
  * Thrown when...
18121
18121
  */
18122
- var NgwError = /** @class */ (function (_super) {
18123
- __extends(NgwError, _super);
18124
- function NgwError(er) {
18122
+ var NetworkError = /** @class */ (function (_super) {
18123
+ __extends(NetworkError, _super);
18124
+ function NetworkError(url) {
18125
18125
  var _this = _super.call(this) || this;
18126
- _this.name = 'NgwError';
18127
- Object.assign(_this, er);
18128
- Object.setPrototypeOf(_this, NgwError.prototype);
18126
+ _this.name = 'NetworkError';
18127
+ Object.setPrototypeOf(_this, NetworkError.prototype);
18128
+ _this.message = "Unable to request ".concat(url, ".\n Possibly invalid NGW URL entered or CORS not configured to get request from ").concat(location.origin); // /control-panel/cors
18129
18129
  return _this;
18130
18130
  }
18131
- return NgwError;
18131
+ return NetworkError;
18132
18132
  }(Error));
18133
18133
 
18134
18134
  /**
18135
18135
  * Thrown when...
18136
18136
  */
18137
- var NetworkError = /** @class */ (function (_super) {
18138
- __extends(NetworkError, _super);
18139
- function NetworkError(url) {
18137
+ var NgwError = /** @class */ (function (_super) {
18138
+ __extends(NgwError, _super);
18139
+ function NgwError(er) {
18140
18140
  var _this = _super.call(this) || this;
18141
- _this.name = 'NetworkError';
18142
- Object.setPrototypeOf(_this, NetworkError.prototype);
18143
- _this.message = "Unable to request ".concat(url, ".\n Possibly invalid NGW URL entered or CORS not configured to get request from ").concat(location.origin); // /control-panel/cors
18141
+ _this.name = 'NgwError';
18142
+ Object.assign(_this, er);
18143
+ Object.setPrototypeOf(_this, NgwError.prototype);
18144
18144
  return _this;
18145
18145
  }
18146
- return NetworkError;
18146
+ return NgwError;
18147
18147
  }(Error));
18148
18148
 
18149
18149
  function isObject(val) {
@@ -18257,11 +18257,6 @@ var NgwLeaflet = (function () {
18257
18257
  xhr.abort();
18258
18258
  });
18259
18259
  }
18260
- if (options.signal) {
18261
- options.signal.addEventListener('abort', function () {
18262
- xhr.abort();
18263
- });
18264
- }
18265
18260
  xhr.send(data);
18266
18261
  };
18267
18262
  }
@@ -19063,7 +19058,7 @@ var NgwLeaflet = (function () {
19063
19058
  NgwConnector.prototype._loadData = function (url, options) {
19064
19059
  var _this = this;
19065
19060
  options.responseType = options.responseType || 'json';
19066
- return new CancelablePromise(function (resolve, reject, onCancel) {
19061
+ var request = new CancelablePromise(function (resolve, reject, onCancel) {
19067
19062
  if (_this.user) {
19068
19063
  options = options || {};
19069
19064
  // options.withCredentials = true;
@@ -19083,6 +19078,13 @@ var NgwLeaflet = (function () {
19083
19078
  }
19084
19079
  }
19085
19080
  });
19081
+ if (options.signal &&
19082
+ typeof options.signal.addEventListener === 'function') {
19083
+ options.signal.addEventListener('abort', function () {
19084
+ request.cancel();
19085
+ });
19086
+ }
19087
+ return request;
19086
19088
  };
19087
19089
  NgwConnector.prototype._handleHttpError = function (er) {
19088
19090
  if (er) {
@@ -19192,12 +19194,12 @@ var NgwLeaflet = (function () {
19192
19194
  function fetchNgwExtent(options) {
19193
19195
  return options.connector.getResource(options.resourceId).then(function (resource) {
19194
19196
  if (resource) {
19195
- return fetchNgwResourceExtent(resource, options.connector);
19197
+ return fetchNgwResourceExtent(resource, options.connector, options);
19196
19198
  }
19197
19199
  });
19198
19200
  }
19199
19201
  /** @deprecated use {@link fetchNgwExtent} instead */
19200
- function fetchNgwResourceExtent(item, connector) {
19202
+ function fetchNgwResourceExtent(item, connector, options) {
19201
19203
  if (item.webmap) {
19202
19204
  return CancelablePromise.resolve(getNgwWebmapExtent(item.webmap));
19203
19205
  }
@@ -19206,15 +19208,12 @@ var NgwLeaflet = (function () {
19206
19208
  if (resource.cls && resource.cls.indexOf('style') !== -1) {
19207
19209
  return connector.getResource(resource.parent.id).then(function (res) {
19208
19210
  if (res) {
19209
- return fetchNgwLayerExtent({
19210
- resourceId: res.resource.id,
19211
- connector: connector,
19212
- });
19211
+ return fetchNgwLayerExtent(__assign(__assign({}, options), { resourceId: res.resource.id, connector: connector }));
19213
19212
  }
19214
19213
  });
19215
19214
  }
19216
19215
  else {
19217
- return fetchNgwLayerExtent({ resourceId: resource.id, connector: connector });
19216
+ return fetchNgwLayerExtent(__assign(__assign({}, options), { resourceId: resource.id, connector: connector }));
19218
19217
  }
19219
19218
  }
19220
19219
  }
@@ -19385,7 +19384,7 @@ var NgwLeaflet = (function () {
19385
19384
  }
19386
19385
  function fetchNgwLayerItemsRequest(options) {
19387
19386
  var params = __assign({}, FEATURE_REQUEST_PARAMS);
19388
- var limit = options.limit, offset = options.offset, orderBy = options.orderBy, paramList = options.paramList, connector = options.connector, intersects = options.intersects, resourceId = options.resourceId;
19387
+ var limit = options.limit, cache = options.cache, signal = options.signal, offset = options.offset, orderBy = options.orderBy, paramList = options.paramList, connector = options.connector, intersects = options.intersects, resourceId = options.resourceId;
19389
19388
  if (limit) {
19390
19389
  if (limit !== Number.POSITIVE_INFINITY) {
19391
19390
  params.limit = limit;
@@ -19415,11 +19414,10 @@ var NgwLeaflet = (function () {
19415
19414
  params.paramList = paramList;
19416
19415
  }
19417
19416
  var reqParams = __assign({ id: resourceId }, params);
19418
- return connector.get('feature_layer.feature.collection', { cache: options.cache }, reqParams);
19417
+ return connector.get('feature_layer.feature.collection', { cache: cache, signal: signal }, reqParams);
19419
19418
  }
19420
19419
 
19421
19420
  function prepareNgwFieldsToPropertiesFilter(fields) {
19422
- console.log(fields);
19423
19421
  var f;
19424
19422
  var _loop_1 = function () {
19425
19423
  var field = fields[f];
@@ -21428,7 +21426,7 @@ var NgwLeaflet = (function () {
21428
21426
  });
21429
21427
  });
21430
21428
  };
21431
- NgwResource.prototype.getBounds = function () {
21429
+ NgwResource.prototype.getBounds = function (options) {
21432
21430
  return __awaiter(this, void 0, void 0, function () {
21433
21431
  var _a;
21434
21432
  return __generator(this, function (_b) {
@@ -21439,7 +21437,7 @@ var NgwLeaflet = (function () {
21439
21437
  }
21440
21438
  if (!this.item) return [3 /*break*/, 2];
21441
21439
  _a = this;
21442
- return [4 /*yield*/, fetchNgwResourceExtent(this.item, this.connector)];
21440
+ return [4 /*yield*/, fetchNgwResourceExtent(this.item, this.connector, options)];
21443
21441
  case 1:
21444
21442
  _a._extent = _b.sent();
21445
21443
  return [2 /*return*/, this._extent];
@@ -22081,7 +22079,7 @@ var NgwLeaflet = (function () {
22081
22079
  return featureParams;
22082
22080
  }
22083
22081
  function fetchIdentifyGeoJson(options) {
22084
- var connector = options.connector, identify = options.identify;
22082
+ var connector = options.connector, identify = options.identify, requestOptions = options.requestOptions;
22085
22083
  for (var l in identify) {
22086
22084
  var id = Number(l);
22087
22085
  if (!isNaN(id)) {
@@ -22097,7 +22095,7 @@ var NgwLeaflet = (function () {
22097
22095
  }
22098
22096
  var params = getIdentifyItems(identify);
22099
22097
  if (params && params.length) {
22100
- return fetchNgwLayerFeature(__assign({ connector: connector }, params[0]));
22098
+ return fetchNgwLayerFeature(__assign(__assign(__assign({}, requestOptions), { connector: connector }), params[0]));
22101
22099
  }
22102
22100
  return CancelablePromise.resolve(undefined);
22103
22101
  }
@@ -22110,21 +22108,25 @@ var NgwLeaflet = (function () {
22110
22108
  return CancelablePromise.resolve(undefined);
22111
22109
  }
22112
22110
  function featureLayerIdentify(options) {
22113
- var g = options.geom;
22114
- var geom = [];
22115
- if (Array.isArray(g)) {
22116
- geom = g;
22111
+ var geom = options.geom, signal = options.signal, cache = options.cache;
22112
+ var geom_ = [];
22113
+ if (Array.isArray(geom)) {
22114
+ geom_ = geom;
22117
22115
  }
22118
22116
  else {
22119
- var polygon = g.type === 'Feature' ? g.geometry : g.type === 'Polygon' ? g : false;
22117
+ var polygon = geom.type === 'Feature'
22118
+ ? geom.geometry
22119
+ : geom.type === 'Polygon'
22120
+ ? geom
22121
+ : false;
22120
22122
  if (polygon) {
22121
- geom = polygon.coordinates[0];
22123
+ geom_ = polygon.coordinates[0];
22122
22124
  }
22123
22125
  }
22124
- if (geom) {
22126
+ if (geom_) {
22125
22127
  // create wkt string
22126
22128
  var polygonStr = [];
22127
- for (var _i = 0, geom_1 = geom; _i < geom_1.length; _i++) {
22129
+ for (var _i = 0, geom_1 = geom_; _i < geom_1.length; _i++) {
22128
22130
  var _a = geom_1[_i], lng = _a[0], lat = _a[1];
22129
22131
  var _b = degrees2meters(lng, lat), x = _b[0], y = _b[1];
22130
22132
  polygonStr.push(x + ' ' + y);
@@ -22136,18 +22138,22 @@ var NgwLeaflet = (function () {
22136
22138
  srs: 3857,
22137
22139
  layers: layers,
22138
22140
  };
22139
- return options.connector.post('feature_layer.identify', { data: data });
22141
+ return options.connector.post('feature_layer.identify', {
22142
+ data: data,
22143
+ signal: signal,
22144
+ cache: cache,
22145
+ });
22140
22146
  }
22141
22147
  else {
22142
22148
  throw new Error('Not valid geometry format to make intersection');
22143
22149
  }
22144
22150
  }
22145
22151
  function sendIdentifyRequest(ev, options) {
22146
- var _a;
22147
22152
  deprecatedMapClick(ev);
22148
- var _b = ev.lngLat, lng = _b[0], lat = _b[1];
22149
- var geom = (_a = options.geom) !== null && _a !== void 0 ? _a : getCirclePolygonCoordinates(lng, lat, options.radius);
22150
- return featureLayerIdentify(__assign(__assign({}, options), { geom: geom }));
22153
+ var _a = ev.lngLat, lng = _a[0], lat = _a[1];
22154
+ var geom = options.geom, radius = options.radius, signal = options.signal, cache = options.cache;
22155
+ var geom_ = geom !== null && geom !== void 0 ? geom : getCirclePolygonCoordinates(lng, lat, radius);
22156
+ return featureLayerIdentify(__assign(__assign({}, options), { geom: geom_, signal: signal, cache: cache }));
22151
22157
  }
22152
22158
  function createIdentifyItem(opt) {
22153
22159
  return new IdentifyItem(opt);