@nextgis/ngw-map 1.13.2 → 1.13.7

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.2; author: NextGIS */
1
+ /** Bundle of @nextgis/ngw-map; version: 1.13.7; author: NextGIS */
2
2
  import { EventEmitter } from 'events';
3
3
  import CancelablePromise from '@nextgis/cancelable-promise';
4
4
  import { deepmerge, isObject, defined, deprecatedWarn } from '@nextgis/utils';
@@ -1,4 +1,4 @@
1
- /** Bundle of @nextgis/ngw-map; version: 1.13.2; author: NextGIS */
1
+ /** Bundle of @nextgis/ngw-map; version: 1.13.7; author: NextGIS */
2
2
  var NgwMap = (function (exports) {
3
3
  'use strict';
4
4
 
@@ -2828,6 +2828,7 @@ var NgwMap = (function (exports) {
2828
2828
  };
2829
2829
  /** Shortcut for {@link WebMapLayers.addLayer} to create TileLayer adapter */
2830
2830
  WebMapLayers.prototype.addTileLayer = function (url, options) {
2831
+ if (options === void 0) { options = {}; }
2831
2832
  return this.addLayer('TILE', __assign(__assign({}, options), { url: url }));
2832
2833
  };
2833
2834
  WebMapLayers.prototype.addImageLayer = function (urlOrOptions, options) {
@@ -4634,6 +4635,7 @@ var NgwMap = (function (exports) {
4634
4635
  this.id = ID$1++;
4635
4636
  this.emitter = new events.exports.EventEmitter();
4636
4637
  this.routeStr = '/api/component/pyramid/route';
4638
+ this.activeRequests = [];
4637
4639
  var exist = findConnector(options);
4638
4640
  if (exist) {
4639
4641
  return exist;
@@ -4719,6 +4721,7 @@ var NgwMap = (function (exports) {
4719
4721
  * Disconnecting a user. Aborting all current requests
4720
4722
  */
4721
4723
  NgwConnector.prototype.logout = function () {
4724
+ this.abort();
4722
4725
  removeConnector(this);
4723
4726
  this.options.auth = undefined;
4724
4727
  this.user = undefined;
@@ -4771,6 +4774,17 @@ var NgwMap = (function (exports) {
4771
4774
  }
4772
4775
  }
4773
4776
  };
4777
+ /** Stop all api requests */
4778
+ NgwConnector.prototype.abort = function () {
4779
+ for (var _i = 0, _a = this.activeRequests; _i < _a.length; _i++) {
4780
+ var req = _a[_i];
4781
+ req.cancel();
4782
+ }
4783
+ this.activeRequests = [];
4784
+ };
4785
+ NgwConnector.prototype.getActiveApiRequests = function () {
4786
+ return __spreadArray([], this.activeRequests, true);
4787
+ };
4774
4788
  /**
4775
4789
  * Send request to NGW api router.
4776
4790
  * @param name - NGW route name from {@link https://docs.nextgis.com/docs_ngweb_dev/doc/developer/resource.html#routes | routes}
@@ -4992,7 +5006,13 @@ var NgwMap = (function (exports) {
4992
5006
  options.headers = __assign(__assign({}, _this.getAuthorizationHeaders()), options.headers);
4993
5007
  }
4994
5008
  loadData(url, resolve, options, reject, onCancel);
4995
- }).catch(function (httpError) {
5009
+ })
5010
+ .then(function (resp) {
5011
+ _this._cleanActiveRequests(request);
5012
+ return resp;
5013
+ })
5014
+ .catch(function (httpError) {
5015
+ _this._cleanActiveRequests(request);
4996
5016
  if (httpError instanceof CancelablePromise.CancelError) ;
4997
5017
  else {
4998
5018
  // @ts-ignore
@@ -5011,8 +5031,15 @@ var NgwMap = (function (exports) {
5011
5031
  request.cancel();
5012
5032
  });
5013
5033
  }
5034
+ this.activeRequests.push(request);
5014
5035
  return request;
5015
5036
  };
5037
+ NgwConnector.prototype._cleanActiveRequests = function (request) {
5038
+ var activeRequestIndex = this.activeRequests.indexOf(request);
5039
+ if (activeRequestIndex !== -1) {
5040
+ this.activeRequests.splice(activeRequestIndex, 1);
5041
+ }
5042
+ };
5016
5043
  NgwConnector.prototype._handleHttpError = function (er) {
5017
5044
  if (er) {
5018
5045
  if (er instanceof NgwError) {
@@ -5837,6 +5864,8 @@ var NgwMap = (function (exports) {
5837
5864
  // url = baseUrl + '/api/resource/' + options.resourceId + '/{z}/{x}/{y}.mvt';
5838
5865
  return {
5839
5866
  url: url,
5867
+ sourceLayer: 'ngw:' + resourceId,
5868
+ featureIdName: '$id',
5840
5869
  };
5841
5870
  }
5842
5871
  if (adapter === 'TERRAIN') {