@nextgis/ngw-map 1.13.0 → 1.13.6
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.
- package/index.js +3 -3
- package/lib/index.d.ts +3 -15
- package/lib/ngw-map.cjs.js +1 -1
- package/lib/ngw-map.cjs.js.map +1 -1
- package/lib/ngw-map.cjs.prod.js.map +1 -1
- package/lib/ngw-map.esm-browser.js +82 -49
- package/lib/ngw-map.esm-browser.js.map +1 -1
- package/lib/ngw-map.esm-browser.prod.js +1 -1
- package/lib/ngw-map.esm-browser.prod.js.map +1 -1
- package/lib/ngw-map.esm-bundler.js +1 -1
- package/lib/ngw-map.esm-bundler.js.map +1 -1
- package/lib/ngw-map.esm-bundler.prod.js.map +1 -1
- package/lib/ngw-map.global.js +82 -49
- package/lib/ngw-map.global.js.map +1 -1
- package/lib/ngw-map.global.prod.js +1 -1
- package/lib/ngw-map.global.prod.js.map +1 -1
- package/package.json +8 -8
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Bundle of @nextgis/ngw-map; version: 1.13.
|
|
1
|
+
/** Bundle of @nextgis/ngw-map; version: 1.13.6; author: NextGIS */
|
|
2
2
|
/*! *****************************************************************************
|
|
3
3
|
Copyright (c) Microsoft Corporation.
|
|
4
4
|
|
|
@@ -2825,6 +2825,7 @@ var WebMapLayers = /** @class */ (function (_super) {
|
|
|
2825
2825
|
};
|
|
2826
2826
|
/** Shortcut for {@link WebMapLayers.addLayer} to create TileLayer adapter */
|
|
2827
2827
|
WebMapLayers.prototype.addTileLayer = function (url, options) {
|
|
2828
|
+
if (options === void 0) { options = {}; }
|
|
2828
2829
|
return this.addLayer('TILE', __assign(__assign({}, options), { url: url }));
|
|
2829
2830
|
};
|
|
2830
2831
|
WebMapLayers.prototype.addImageLayer = function (urlOrOptions, options) {
|
|
@@ -4043,31 +4044,31 @@ var Cache = Cache$1;
|
|
|
4043
4044
|
/**
|
|
4044
4045
|
* Thrown when...
|
|
4045
4046
|
*/
|
|
4046
|
-
var
|
|
4047
|
-
__extends(
|
|
4048
|
-
function
|
|
4047
|
+
var NetworkError = /** @class */ (function (_super) {
|
|
4048
|
+
__extends(NetworkError, _super);
|
|
4049
|
+
function NetworkError(url) {
|
|
4049
4050
|
var _this = _super.call(this) || this;
|
|
4050
|
-
_this.name = '
|
|
4051
|
-
Object.
|
|
4052
|
-
|
|
4051
|
+
_this.name = 'NetworkError';
|
|
4052
|
+
Object.setPrototypeOf(_this, NetworkError.prototype);
|
|
4053
|
+
_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
4054
|
return _this;
|
|
4054
4055
|
}
|
|
4055
|
-
return
|
|
4056
|
+
return NetworkError;
|
|
4056
4057
|
}(Error));
|
|
4057
4058
|
|
|
4058
4059
|
/**
|
|
4059
4060
|
* Thrown when...
|
|
4060
4061
|
*/
|
|
4061
|
-
var
|
|
4062
|
-
__extends(
|
|
4063
|
-
function
|
|
4062
|
+
var NgwError = /** @class */ (function (_super) {
|
|
4063
|
+
__extends(NgwError, _super);
|
|
4064
|
+
function NgwError(er) {
|
|
4064
4065
|
var _this = _super.call(this) || this;
|
|
4065
|
-
_this.name = '
|
|
4066
|
-
Object.
|
|
4067
|
-
|
|
4066
|
+
_this.name = 'NgwError';
|
|
4067
|
+
Object.assign(_this, er);
|
|
4068
|
+
Object.setPrototypeOf(_this, NgwError.prototype);
|
|
4068
4069
|
return _this;
|
|
4069
4070
|
}
|
|
4070
|
-
return
|
|
4071
|
+
return NgwError;
|
|
4071
4072
|
}(Error));
|
|
4072
4073
|
|
|
4073
4074
|
function isObject(val) {
|
|
@@ -4181,11 +4182,6 @@ var loadData;
|
|
|
4181
4182
|
xhr.abort();
|
|
4182
4183
|
});
|
|
4183
4184
|
}
|
|
4184
|
-
if (options.signal) {
|
|
4185
|
-
options.signal.addEventListener('abort', function () {
|
|
4186
|
-
xhr.abort();
|
|
4187
|
-
});
|
|
4188
|
-
}
|
|
4189
4185
|
xhr.send(data);
|
|
4190
4186
|
};
|
|
4191
4187
|
}
|
|
@@ -4636,6 +4632,7 @@ var NgwConnector$1 = /** @class */ (function () {
|
|
|
4636
4632
|
this.id = ID$1++;
|
|
4637
4633
|
this.emitter = new events.exports.EventEmitter();
|
|
4638
4634
|
this.routeStr = '/api/component/pyramid/route';
|
|
4635
|
+
this.activeRequests = [];
|
|
4639
4636
|
var exist = findConnector(options);
|
|
4640
4637
|
if (exist) {
|
|
4641
4638
|
return exist;
|
|
@@ -4721,6 +4718,7 @@ var NgwConnector$1 = /** @class */ (function () {
|
|
|
4721
4718
|
* Disconnecting a user. Aborting all current requests
|
|
4722
4719
|
*/
|
|
4723
4720
|
NgwConnector.prototype.logout = function () {
|
|
4721
|
+
this.abort();
|
|
4724
4722
|
removeConnector(this);
|
|
4725
4723
|
this.options.auth = undefined;
|
|
4726
4724
|
this.user = undefined;
|
|
@@ -4773,6 +4771,17 @@ var NgwConnector$1 = /** @class */ (function () {
|
|
|
4773
4771
|
}
|
|
4774
4772
|
}
|
|
4775
4773
|
};
|
|
4774
|
+
/** Stop all api requests */
|
|
4775
|
+
NgwConnector.prototype.abort = function () {
|
|
4776
|
+
for (var _i = 0, _a = this.activeRequests; _i < _a.length; _i++) {
|
|
4777
|
+
var req = _a[_i];
|
|
4778
|
+
req.cancel();
|
|
4779
|
+
}
|
|
4780
|
+
this.activeRequests = [];
|
|
4781
|
+
};
|
|
4782
|
+
NgwConnector.prototype.getActiveApiRequests = function () {
|
|
4783
|
+
return __spreadArray([], this.activeRequests, true);
|
|
4784
|
+
};
|
|
4776
4785
|
/**
|
|
4777
4786
|
* Send request to NGW api router.
|
|
4778
4787
|
* @param name - NGW route name from {@link https://docs.nextgis.com/docs_ngweb_dev/doc/developer/resource.html#routes | routes}
|
|
@@ -4987,14 +4996,20 @@ var NgwConnector$1 = /** @class */ (function () {
|
|
|
4987
4996
|
NgwConnector.prototype._loadData = function (url, options) {
|
|
4988
4997
|
var _this = this;
|
|
4989
4998
|
options.responseType = options.responseType || 'json';
|
|
4990
|
-
|
|
4999
|
+
var request = new CancelablePromise(function (resolve, reject, onCancel) {
|
|
4991
5000
|
if (_this.user) {
|
|
4992
5001
|
options = options || {};
|
|
4993
5002
|
// options.withCredentials = true;
|
|
4994
5003
|
options.headers = __assign(__assign({}, _this.getAuthorizationHeaders()), options.headers);
|
|
4995
5004
|
}
|
|
4996
5005
|
loadData(url, resolve, options, reject, onCancel);
|
|
4997
|
-
})
|
|
5006
|
+
})
|
|
5007
|
+
.then(function (resp) {
|
|
5008
|
+
_this._cleanActiveRequests(request);
|
|
5009
|
+
return resp;
|
|
5010
|
+
})
|
|
5011
|
+
.catch(function (httpError) {
|
|
5012
|
+
_this._cleanActiveRequests(request);
|
|
4998
5013
|
if (httpError instanceof CancelablePromise.CancelError) ;
|
|
4999
5014
|
else {
|
|
5000
5015
|
// @ts-ignore
|
|
@@ -5007,6 +5022,20 @@ var NgwConnector$1 = /** @class */ (function () {
|
|
|
5007
5022
|
}
|
|
5008
5023
|
}
|
|
5009
5024
|
});
|
|
5025
|
+
if (options.signal &&
|
|
5026
|
+
typeof options.signal.addEventListener === 'function') {
|
|
5027
|
+
options.signal.addEventListener('abort', function () {
|
|
5028
|
+
request.cancel();
|
|
5029
|
+
});
|
|
5030
|
+
}
|
|
5031
|
+
this.activeRequests.push(request);
|
|
5032
|
+
return request;
|
|
5033
|
+
};
|
|
5034
|
+
NgwConnector.prototype._cleanActiveRequests = function (request) {
|
|
5035
|
+
var activeRequestIndex = this.activeRequests.indexOf(request);
|
|
5036
|
+
if (activeRequestIndex !== -1) {
|
|
5037
|
+
this.activeRequests.splice(activeRequestIndex, 1);
|
|
5038
|
+
}
|
|
5010
5039
|
};
|
|
5011
5040
|
NgwConnector.prototype._handleHttpError = function (er) {
|
|
5012
5041
|
if (er) {
|
|
@@ -5128,12 +5157,12 @@ function fetchNgwLayerItemExtent(_a) {
|
|
|
5128
5157
|
function fetchNgwExtent(options) {
|
|
5129
5158
|
return options.connector.getResource(options.resourceId).then(function (resource) {
|
|
5130
5159
|
if (resource) {
|
|
5131
|
-
return fetchNgwResourceExtent(resource, options.connector);
|
|
5160
|
+
return fetchNgwResourceExtent(resource, options.connector, options);
|
|
5132
5161
|
}
|
|
5133
5162
|
});
|
|
5134
5163
|
}
|
|
5135
5164
|
/** @deprecated use {@link fetchNgwExtent} instead */
|
|
5136
|
-
function fetchNgwResourceExtent(item, connector) {
|
|
5165
|
+
function fetchNgwResourceExtent(item, connector, options) {
|
|
5137
5166
|
if (item.webmap) {
|
|
5138
5167
|
return CancelablePromise.resolve(getNgwWebmapExtent(item.webmap));
|
|
5139
5168
|
}
|
|
@@ -5142,15 +5171,12 @@ function fetchNgwResourceExtent(item, connector) {
|
|
|
5142
5171
|
if (resource.cls && resource.cls.indexOf('style') !== -1) {
|
|
5143
5172
|
return connector.getResource(resource.parent.id).then(function (res) {
|
|
5144
5173
|
if (res) {
|
|
5145
|
-
return fetchNgwLayerExtent({
|
|
5146
|
-
resourceId: res.resource.id,
|
|
5147
|
-
connector: connector,
|
|
5148
|
-
});
|
|
5174
|
+
return fetchNgwLayerExtent(__assign(__assign({}, options), { resourceId: res.resource.id, connector: connector }));
|
|
5149
5175
|
}
|
|
5150
5176
|
});
|
|
5151
5177
|
}
|
|
5152
5178
|
else {
|
|
5153
|
-
return fetchNgwLayerExtent({ resourceId: resource.id, connector: connector });
|
|
5179
|
+
return fetchNgwLayerExtent(__assign(__assign({}, options), { resourceId: resource.id, connector: connector }));
|
|
5154
5180
|
}
|
|
5155
5181
|
}
|
|
5156
5182
|
}
|
|
@@ -5321,7 +5347,7 @@ function createWktFromCoordArray(coord) {
|
|
|
5321
5347
|
}
|
|
5322
5348
|
function fetchNgwLayerItemsRequest(options) {
|
|
5323
5349
|
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;
|
|
5350
|
+
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
5351
|
if (limit) {
|
|
5326
5352
|
if (limit !== Number.POSITIVE_INFINITY) {
|
|
5327
5353
|
params.limit = limit;
|
|
@@ -5351,11 +5377,10 @@ function fetchNgwLayerItemsRequest(options) {
|
|
|
5351
5377
|
params.paramList = paramList;
|
|
5352
5378
|
}
|
|
5353
5379
|
var reqParams = __assign({ id: resourceId }, params);
|
|
5354
|
-
return connector.get('feature_layer.feature.collection', { cache:
|
|
5380
|
+
return connector.get('feature_layer.feature.collection', { cache: cache, signal: signal }, reqParams);
|
|
5355
5381
|
}
|
|
5356
5382
|
|
|
5357
5383
|
function prepareNgwFieldsToPropertiesFilter(fields) {
|
|
5358
|
-
console.log(fields);
|
|
5359
5384
|
var f;
|
|
5360
5385
|
var _loop_1 = function () {
|
|
5361
5386
|
var field = fields[f];
|
|
@@ -7364,7 +7389,7 @@ var NgwResource = /** @class */ (function () {
|
|
|
7364
7389
|
});
|
|
7365
7390
|
});
|
|
7366
7391
|
};
|
|
7367
|
-
NgwResource.prototype.getBounds = function () {
|
|
7392
|
+
NgwResource.prototype.getBounds = function (options) {
|
|
7368
7393
|
return __awaiter(this, void 0, void 0, function () {
|
|
7369
7394
|
var _a;
|
|
7370
7395
|
return __generator(this, function (_b) {
|
|
@@ -7375,7 +7400,7 @@ var NgwResource = /** @class */ (function () {
|
|
|
7375
7400
|
}
|
|
7376
7401
|
if (!this.item) return [3 /*break*/, 2];
|
|
7377
7402
|
_a = this;
|
|
7378
|
-
return [4 /*yield*/, fetchNgwResourceExtent(this.item, this.connector)];
|
|
7403
|
+
return [4 /*yield*/, fetchNgwResourceExtent(this.item, this.connector, options)];
|
|
7379
7404
|
case 1:
|
|
7380
7405
|
_a._extent = _b.sent();
|
|
7381
7406
|
return [2 /*return*/, this._extent];
|
|
@@ -8017,7 +8042,7 @@ function createParamsFromFeatures(features, resourceId, multiple) {
|
|
|
8017
8042
|
return featureParams;
|
|
8018
8043
|
}
|
|
8019
8044
|
function fetchIdentifyGeoJson(options) {
|
|
8020
|
-
var connector = options.connector, identify = options.identify;
|
|
8045
|
+
var connector = options.connector, identify = options.identify, requestOptions = options.requestOptions;
|
|
8021
8046
|
for (var l in identify) {
|
|
8022
8047
|
var id = Number(l);
|
|
8023
8048
|
if (!isNaN(id)) {
|
|
@@ -8033,7 +8058,7 @@ function fetchIdentifyGeoJson(options) {
|
|
|
8033
8058
|
}
|
|
8034
8059
|
var params = getIdentifyItems(identify);
|
|
8035
8060
|
if (params && params.length) {
|
|
8036
|
-
return fetchNgwLayerFeature(__assign({ connector: connector }, params[0]));
|
|
8061
|
+
return fetchNgwLayerFeature(__assign(__assign(__assign({}, requestOptions), { connector: connector }), params[0]));
|
|
8037
8062
|
}
|
|
8038
8063
|
return CancelablePromise.resolve(undefined);
|
|
8039
8064
|
}
|
|
@@ -8046,21 +8071,25 @@ function fetchIdentifyItem(options) {
|
|
|
8046
8071
|
return CancelablePromise.resolve(undefined);
|
|
8047
8072
|
}
|
|
8048
8073
|
function featureLayerIdentify(options) {
|
|
8049
|
-
var
|
|
8050
|
-
var
|
|
8051
|
-
if (Array.isArray(
|
|
8052
|
-
|
|
8074
|
+
var geom = options.geom, signal = options.signal, cache = options.cache;
|
|
8075
|
+
var geom_ = [];
|
|
8076
|
+
if (Array.isArray(geom)) {
|
|
8077
|
+
geom_ = geom;
|
|
8053
8078
|
}
|
|
8054
8079
|
else {
|
|
8055
|
-
var polygon =
|
|
8080
|
+
var polygon = geom.type === 'Feature'
|
|
8081
|
+
? geom.geometry
|
|
8082
|
+
: geom.type === 'Polygon'
|
|
8083
|
+
? geom
|
|
8084
|
+
: false;
|
|
8056
8085
|
if (polygon) {
|
|
8057
|
-
|
|
8086
|
+
geom_ = polygon.coordinates[0];
|
|
8058
8087
|
}
|
|
8059
8088
|
}
|
|
8060
|
-
if (
|
|
8089
|
+
if (geom_) {
|
|
8061
8090
|
// create wkt string
|
|
8062
8091
|
var polygonStr = [];
|
|
8063
|
-
for (var _i = 0, geom_1 =
|
|
8092
|
+
for (var _i = 0, geom_1 = geom_; _i < geom_1.length; _i++) {
|
|
8064
8093
|
var _a = geom_1[_i], lng = _a[0], lat = _a[1];
|
|
8065
8094
|
var _b = degrees2meters(lng, lat), x = _b[0], y = _b[1];
|
|
8066
8095
|
polygonStr.push(x + ' ' + y);
|
|
@@ -8072,18 +8101,22 @@ function featureLayerIdentify(options) {
|
|
|
8072
8101
|
srs: 3857,
|
|
8073
8102
|
layers: layers,
|
|
8074
8103
|
};
|
|
8075
|
-
return options.connector.post('feature_layer.identify', {
|
|
8104
|
+
return options.connector.post('feature_layer.identify', {
|
|
8105
|
+
data: data,
|
|
8106
|
+
signal: signal,
|
|
8107
|
+
cache: cache,
|
|
8108
|
+
});
|
|
8076
8109
|
}
|
|
8077
8110
|
else {
|
|
8078
8111
|
throw new Error('Not valid geometry format to make intersection');
|
|
8079
8112
|
}
|
|
8080
8113
|
}
|
|
8081
8114
|
function sendIdentifyRequest(ev, options) {
|
|
8082
|
-
var _a;
|
|
8083
8115
|
deprecatedMapClick(ev);
|
|
8084
|
-
var
|
|
8085
|
-
var geom =
|
|
8086
|
-
|
|
8116
|
+
var _a = ev.lngLat, lng = _a[0], lat = _a[1];
|
|
8117
|
+
var geom = options.geom, radius = options.radius, signal = options.signal, cache = options.cache;
|
|
8118
|
+
var geom_ = geom !== null && geom !== void 0 ? geom : getCirclePolygonCoordinates(lng, lat, radius);
|
|
8119
|
+
return featureLayerIdentify(__assign(__assign({}, options), { geom: geom_, signal: signal, cache: cache }));
|
|
8087
8120
|
}
|
|
8088
8121
|
function createIdentifyItem(opt) {
|
|
8089
8122
|
return new IdentifyItem(opt);
|