@nextgis/ngw-map 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-map; version: 1.13.0; author: NextGIS */
1
+ /** Bundle of @nextgis/ngw-map; version: 1.13.2; author: NextGIS */
2
2
  /*! *****************************************************************************
3
3
  Copyright (c) Microsoft Corporation.
4
4
 
@@ -4043,31 +4043,31 @@ var Cache = Cache$1;
4043
4043
  /**
4044
4044
  * Thrown when...
4045
4045
  */
4046
- var NgwError = /** @class */ (function (_super) {
4047
- __extends(NgwError, _super);
4048
- function NgwError(er) {
4046
+ var NetworkError = /** @class */ (function (_super) {
4047
+ __extends(NetworkError, _super);
4048
+ function NetworkError(url) {
4049
4049
  var _this = _super.call(this) || this;
4050
- _this.name = 'NgwError';
4051
- Object.assign(_this, er);
4052
- Object.setPrototypeOf(_this, NgwError.prototype);
4050
+ _this.name = 'NetworkError';
4051
+ Object.setPrototypeOf(_this, NetworkError.prototype);
4052
+ _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
4053
4053
  return _this;
4054
4054
  }
4055
- return NgwError;
4055
+ return NetworkError;
4056
4056
  }(Error));
4057
4057
 
4058
4058
  /**
4059
4059
  * Thrown when...
4060
4060
  */
4061
- var NetworkError = /** @class */ (function (_super) {
4062
- __extends(NetworkError, _super);
4063
- function NetworkError(url) {
4061
+ var NgwError = /** @class */ (function (_super) {
4062
+ __extends(NgwError, _super);
4063
+ function NgwError(er) {
4064
4064
  var _this = _super.call(this) || this;
4065
- _this.name = 'NetworkError';
4066
- Object.setPrototypeOf(_this, NetworkError.prototype);
4067
- _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
4065
+ _this.name = 'NgwError';
4066
+ Object.assign(_this, er);
4067
+ Object.setPrototypeOf(_this, NgwError.prototype);
4068
4068
  return _this;
4069
4069
  }
4070
- return NetworkError;
4070
+ return NgwError;
4071
4071
  }(Error));
4072
4072
 
4073
4073
  function isObject(val) {
@@ -4181,11 +4181,6 @@ var loadData;
4181
4181
  xhr.abort();
4182
4182
  });
4183
4183
  }
4184
- if (options.signal) {
4185
- options.signal.addEventListener('abort', function () {
4186
- xhr.abort();
4187
- });
4188
- }
4189
4184
  xhr.send(data);
4190
4185
  };
4191
4186
  }
@@ -4987,7 +4982,7 @@ var NgwConnector$1 = /** @class */ (function () {
4987
4982
  NgwConnector.prototype._loadData = function (url, options) {
4988
4983
  var _this = this;
4989
4984
  options.responseType = options.responseType || 'json';
4990
- return new CancelablePromise(function (resolve, reject, onCancel) {
4985
+ var request = new CancelablePromise(function (resolve, reject, onCancel) {
4991
4986
  if (_this.user) {
4992
4987
  options = options || {};
4993
4988
  // options.withCredentials = true;
@@ -5007,6 +5002,13 @@ var NgwConnector$1 = /** @class */ (function () {
5007
5002
  }
5008
5003
  }
5009
5004
  });
5005
+ if (options.signal &&
5006
+ typeof options.signal.addEventListener === 'function') {
5007
+ options.signal.addEventListener('abort', function () {
5008
+ request.cancel();
5009
+ });
5010
+ }
5011
+ return request;
5010
5012
  };
5011
5013
  NgwConnector.prototype._handleHttpError = function (er) {
5012
5014
  if (er) {
@@ -5128,12 +5130,12 @@ function fetchNgwLayerItemExtent(_a) {
5128
5130
  function fetchNgwExtent(options) {
5129
5131
  return options.connector.getResource(options.resourceId).then(function (resource) {
5130
5132
  if (resource) {
5131
- return fetchNgwResourceExtent(resource, options.connector);
5133
+ return fetchNgwResourceExtent(resource, options.connector, options);
5132
5134
  }
5133
5135
  });
5134
5136
  }
5135
5137
  /** @deprecated use {@link fetchNgwExtent} instead */
5136
- function fetchNgwResourceExtent(item, connector) {
5138
+ function fetchNgwResourceExtent(item, connector, options) {
5137
5139
  if (item.webmap) {
5138
5140
  return CancelablePromise.resolve(getNgwWebmapExtent(item.webmap));
5139
5141
  }
@@ -5142,15 +5144,12 @@ function fetchNgwResourceExtent(item, connector) {
5142
5144
  if (resource.cls && resource.cls.indexOf('style') !== -1) {
5143
5145
  return connector.getResource(resource.parent.id).then(function (res) {
5144
5146
  if (res) {
5145
- return fetchNgwLayerExtent({
5146
- resourceId: res.resource.id,
5147
- connector: connector,
5148
- });
5147
+ return fetchNgwLayerExtent(__assign(__assign({}, options), { resourceId: res.resource.id, connector: connector }));
5149
5148
  }
5150
5149
  });
5151
5150
  }
5152
5151
  else {
5153
- return fetchNgwLayerExtent({ resourceId: resource.id, connector: connector });
5152
+ return fetchNgwLayerExtent(__assign(__assign({}, options), { resourceId: resource.id, connector: connector }));
5154
5153
  }
5155
5154
  }
5156
5155
  }
@@ -5321,7 +5320,7 @@ function createWktFromCoordArray(coord) {
5321
5320
  }
5322
5321
  function fetchNgwLayerItemsRequest(options) {
5323
5322
  var params = __assign({}, FEATURE_REQUEST_PARAMS);
5324
- var limit = options.limit, offset = options.offset, orderBy = options.orderBy, paramList = options.paramList, connector = options.connector, intersects = options.intersects, resourceId = options.resourceId;
5323
+ 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;
5325
5324
  if (limit) {
5326
5325
  if (limit !== Number.POSITIVE_INFINITY) {
5327
5326
  params.limit = limit;
@@ -5351,11 +5350,10 @@ function fetchNgwLayerItemsRequest(options) {
5351
5350
  params.paramList = paramList;
5352
5351
  }
5353
5352
  var reqParams = __assign({ id: resourceId }, params);
5354
- return connector.get('feature_layer.feature.collection', { cache: options.cache }, reqParams);
5353
+ return connector.get('feature_layer.feature.collection', { cache: cache, signal: signal }, reqParams);
5355
5354
  }
5356
5355
 
5357
5356
  function prepareNgwFieldsToPropertiesFilter(fields) {
5358
- console.log(fields);
5359
5357
  var f;
5360
5358
  var _loop_1 = function () {
5361
5359
  var field = fields[f];
@@ -7364,7 +7362,7 @@ var NgwResource = /** @class */ (function () {
7364
7362
  });
7365
7363
  });
7366
7364
  };
7367
- NgwResource.prototype.getBounds = function () {
7365
+ NgwResource.prototype.getBounds = function (options) {
7368
7366
  return __awaiter(this, void 0, void 0, function () {
7369
7367
  var _a;
7370
7368
  return __generator(this, function (_b) {
@@ -7375,7 +7373,7 @@ var NgwResource = /** @class */ (function () {
7375
7373
  }
7376
7374
  if (!this.item) return [3 /*break*/, 2];
7377
7375
  _a = this;
7378
- return [4 /*yield*/, fetchNgwResourceExtent(this.item, this.connector)];
7376
+ return [4 /*yield*/, fetchNgwResourceExtent(this.item, this.connector, options)];
7379
7377
  case 1:
7380
7378
  _a._extent = _b.sent();
7381
7379
  return [2 /*return*/, this._extent];
@@ -8017,7 +8015,7 @@ function createParamsFromFeatures(features, resourceId, multiple) {
8017
8015
  return featureParams;
8018
8016
  }
8019
8017
  function fetchIdentifyGeoJson(options) {
8020
- var connector = options.connector, identify = options.identify;
8018
+ var connector = options.connector, identify = options.identify, requestOptions = options.requestOptions;
8021
8019
  for (var l in identify) {
8022
8020
  var id = Number(l);
8023
8021
  if (!isNaN(id)) {
@@ -8033,7 +8031,7 @@ function fetchIdentifyGeoJson(options) {
8033
8031
  }
8034
8032
  var params = getIdentifyItems(identify);
8035
8033
  if (params && params.length) {
8036
- return fetchNgwLayerFeature(__assign({ connector: connector }, params[0]));
8034
+ return fetchNgwLayerFeature(__assign(__assign(__assign({}, requestOptions), { connector: connector }), params[0]));
8037
8035
  }
8038
8036
  return CancelablePromise.resolve(undefined);
8039
8037
  }
@@ -8046,21 +8044,25 @@ function fetchIdentifyItem(options) {
8046
8044
  return CancelablePromise.resolve(undefined);
8047
8045
  }
8048
8046
  function featureLayerIdentify(options) {
8049
- var g = options.geom;
8050
- var geom = [];
8051
- if (Array.isArray(g)) {
8052
- geom = g;
8047
+ var geom = options.geom, signal = options.signal, cache = options.cache;
8048
+ var geom_ = [];
8049
+ if (Array.isArray(geom)) {
8050
+ geom_ = geom;
8053
8051
  }
8054
8052
  else {
8055
- var polygon = g.type === 'Feature' ? g.geometry : g.type === 'Polygon' ? g : false;
8053
+ var polygon = geom.type === 'Feature'
8054
+ ? geom.geometry
8055
+ : geom.type === 'Polygon'
8056
+ ? geom
8057
+ : false;
8056
8058
  if (polygon) {
8057
- geom = polygon.coordinates[0];
8059
+ geom_ = polygon.coordinates[0];
8058
8060
  }
8059
8061
  }
8060
- if (geom) {
8062
+ if (geom_) {
8061
8063
  // create wkt string
8062
8064
  var polygonStr = [];
8063
- for (var _i = 0, geom_1 = geom; _i < geom_1.length; _i++) {
8065
+ for (var _i = 0, geom_1 = geom_; _i < geom_1.length; _i++) {
8064
8066
  var _a = geom_1[_i], lng = _a[0], lat = _a[1];
8065
8067
  var _b = degrees2meters(lng, lat), x = _b[0], y = _b[1];
8066
8068
  polygonStr.push(x + ' ' + y);
@@ -8072,18 +8074,22 @@ function featureLayerIdentify(options) {
8072
8074
  srs: 3857,
8073
8075
  layers: layers,
8074
8076
  };
8075
- return options.connector.post('feature_layer.identify', { data: data });
8077
+ return options.connector.post('feature_layer.identify', {
8078
+ data: data,
8079
+ signal: signal,
8080
+ cache: cache,
8081
+ });
8076
8082
  }
8077
8083
  else {
8078
8084
  throw new Error('Not valid geometry format to make intersection');
8079
8085
  }
8080
8086
  }
8081
8087
  function sendIdentifyRequest(ev, options) {
8082
- var _a;
8083
8088
  deprecatedMapClick(ev);
8084
- var _b = ev.lngLat, lng = _b[0], lat = _b[1];
8085
- var geom = (_a = options.geom) !== null && _a !== void 0 ? _a : getCirclePolygonCoordinates(lng, lat, options.radius);
8086
- return featureLayerIdentify(__assign(__assign({}, options), { geom: geom }));
8089
+ var _a = ev.lngLat, lng = _a[0], lat = _a[1];
8090
+ var geom = options.geom, radius = options.radius, signal = options.signal, cache = options.cache;
8091
+ var geom_ = geom !== null && geom !== void 0 ? geom : getCirclePolygonCoordinates(lng, lat, radius);
8092
+ return featureLayerIdentify(__assign(__assign({}, options), { geom: geom_, signal: signal, cache: cache }));
8087
8093
  }
8088
8094
  function createIdentifyItem(opt) {
8089
8095
  return new IdentifyItem(opt);