@nextgis/ngw-map 1.12.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.
- package/index.js +3 -3
- package/lib/index.d.ts +5 -17
- 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 +132 -66
- 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 +132 -66
- 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.
|
|
1
|
+
/** Bundle of @nextgis/ngw-map; version: 1.13.2; author: NextGIS */
|
|
2
2
|
/*! *****************************************************************************
|
|
3
3
|
Copyright (c) Microsoft Corporation.
|
|
4
4
|
|
|
@@ -1305,6 +1305,9 @@ function objectRemoveEmpty(obj) {
|
|
|
1305
1305
|
|
|
1306
1306
|
function isObject$1(val) {
|
|
1307
1307
|
return Object.prototype.toString.call(val) === '[object Object]';
|
|
1308
|
+
}
|
|
1309
|
+
function isArray(val) {
|
|
1310
|
+
return Object.prototype.toString.call(val) === '[object Array]';
|
|
1308
1311
|
}
|
|
1309
1312
|
|
|
1310
1313
|
function fixUrlStr(url) {
|
|
@@ -2368,6 +2371,9 @@ var WebMapMain = /** @class */ (function () {
|
|
|
2368
2371
|
'movestart',
|
|
2369
2372
|
'move',
|
|
2370
2373
|
'moveend',
|
|
2374
|
+
'mousemove',
|
|
2375
|
+
'mouseout',
|
|
2376
|
+
'mouseover',
|
|
2371
2377
|
];
|
|
2372
2378
|
if (opt && opt.include) {
|
|
2373
2379
|
events = events.filter(function (x) { return opt.include.includes(x); });
|
|
@@ -4037,31 +4043,31 @@ var Cache = Cache$1;
|
|
|
4037
4043
|
/**
|
|
4038
4044
|
* Thrown when...
|
|
4039
4045
|
*/
|
|
4040
|
-
var
|
|
4041
|
-
__extends(
|
|
4042
|
-
function
|
|
4046
|
+
var NetworkError = /** @class */ (function (_super) {
|
|
4047
|
+
__extends(NetworkError, _super);
|
|
4048
|
+
function NetworkError(url) {
|
|
4043
4049
|
var _this = _super.call(this) || this;
|
|
4044
|
-
_this.name = '
|
|
4045
|
-
Object.
|
|
4046
|
-
|
|
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
|
|
4047
4053
|
return _this;
|
|
4048
4054
|
}
|
|
4049
|
-
return
|
|
4055
|
+
return NetworkError;
|
|
4050
4056
|
}(Error));
|
|
4051
4057
|
|
|
4052
4058
|
/**
|
|
4053
4059
|
* Thrown when...
|
|
4054
4060
|
*/
|
|
4055
|
-
var
|
|
4056
|
-
__extends(
|
|
4057
|
-
function
|
|
4061
|
+
var NgwError = /** @class */ (function (_super) {
|
|
4062
|
+
__extends(NgwError, _super);
|
|
4063
|
+
function NgwError(er) {
|
|
4058
4064
|
var _this = _super.call(this) || this;
|
|
4059
|
-
_this.name = '
|
|
4060
|
-
Object.
|
|
4061
|
-
|
|
4065
|
+
_this.name = 'NgwError';
|
|
4066
|
+
Object.assign(_this, er);
|
|
4067
|
+
Object.setPrototypeOf(_this, NgwError.prototype);
|
|
4062
4068
|
return _this;
|
|
4063
4069
|
}
|
|
4064
|
-
return
|
|
4070
|
+
return NgwError;
|
|
4065
4071
|
}(Error));
|
|
4066
4072
|
|
|
4067
4073
|
function isObject(val) {
|
|
@@ -4316,7 +4322,12 @@ var ResourcesControl = /** @class */ (function () {
|
|
|
4316
4322
|
forCache.id = resource;
|
|
4317
4323
|
}
|
|
4318
4324
|
else if (isObject(resource)) {
|
|
4319
|
-
|
|
4325
|
+
if (resource.id !== undefined) {
|
|
4326
|
+
forCache.id = resource.id;
|
|
4327
|
+
}
|
|
4328
|
+
else if (resource.keyname) {
|
|
4329
|
+
forCache.keyname = resource.keyname;
|
|
4330
|
+
}
|
|
4320
4331
|
}
|
|
4321
4332
|
var makeRequest = function () {
|
|
4322
4333
|
if (typeof resource === 'string') {
|
|
@@ -4418,20 +4429,35 @@ var ResourcesControl = /** @class */ (function () {
|
|
|
4418
4429
|
};
|
|
4419
4430
|
ResourcesControl.prototype.getChildrenOf = function (resource, requestOptions) {
|
|
4420
4431
|
var _this = this;
|
|
4421
|
-
return this.
|
|
4422
|
-
return _this.
|
|
4423
|
-
|
|
4424
|
-
|
|
4425
|
-
|
|
4426
|
-
|
|
4427
|
-
|
|
4428
|
-
|
|
4429
|
-
|
|
4430
|
-
|
|
4431
|
-
|
|
4432
|
+
return this.getIdOrFail(resource).then(function (parent) {
|
|
4433
|
+
return _this._getChildrenOf(parent, requestOptions);
|
|
4434
|
+
});
|
|
4435
|
+
};
|
|
4436
|
+
ResourcesControl.prototype._getChildrenOf = function (parent, requestOptions, _items) {
|
|
4437
|
+
var _this = this;
|
|
4438
|
+
if (_items === void 0) { _items = []; }
|
|
4439
|
+
return this.connector
|
|
4440
|
+
.get('resource.collection', __assign({ cache: true }, requestOptions), {
|
|
4441
|
+
parent: parent,
|
|
4442
|
+
})
|
|
4443
|
+
.then(function (items) {
|
|
4444
|
+
var recursivePromises = [];
|
|
4445
|
+
for (var _i = 0, items_1 = items; _i < items_1.length; _i++) {
|
|
4446
|
+
var item = items_1[_i];
|
|
4447
|
+
_this.cache.add('resource.item', CancelablePromise.resolve(item), {
|
|
4448
|
+
id: item.resource.id,
|
|
4449
|
+
});
|
|
4450
|
+
_items.push(item);
|
|
4451
|
+
if ((requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.recursive) && item.resource.children) {
|
|
4452
|
+
recursivePromises.push(_this._getChildrenOf(item.resource.id, requestOptions, _items));
|
|
4432
4453
|
}
|
|
4433
|
-
|
|
4434
|
-
|
|
4454
|
+
}
|
|
4455
|
+
if (recursivePromises.length) {
|
|
4456
|
+
return CancelablePromise.all(recursivePromises).then(function () {
|
|
4457
|
+
return _items;
|
|
4458
|
+
});
|
|
4459
|
+
}
|
|
4460
|
+
return _items;
|
|
4435
4461
|
});
|
|
4436
4462
|
};
|
|
4437
4463
|
ResourcesControl.prototype.update = function (resource, data) {
|
|
@@ -4956,7 +4982,7 @@ var NgwConnector$1 = /** @class */ (function () {
|
|
|
4956
4982
|
NgwConnector.prototype._loadData = function (url, options) {
|
|
4957
4983
|
var _this = this;
|
|
4958
4984
|
options.responseType = options.responseType || 'json';
|
|
4959
|
-
|
|
4985
|
+
var request = new CancelablePromise(function (resolve, reject, onCancel) {
|
|
4960
4986
|
if (_this.user) {
|
|
4961
4987
|
options = options || {};
|
|
4962
4988
|
// options.withCredentials = true;
|
|
@@ -4976,6 +5002,13 @@ var NgwConnector$1 = /** @class */ (function () {
|
|
|
4976
5002
|
}
|
|
4977
5003
|
}
|
|
4978
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;
|
|
4979
5012
|
};
|
|
4980
5013
|
NgwConnector.prototype._handleHttpError = function (er) {
|
|
4981
5014
|
if (er) {
|
|
@@ -5097,12 +5130,12 @@ function fetchNgwLayerItemExtent(_a) {
|
|
|
5097
5130
|
function fetchNgwExtent(options) {
|
|
5098
5131
|
return options.connector.getResource(options.resourceId).then(function (resource) {
|
|
5099
5132
|
if (resource) {
|
|
5100
|
-
return fetchNgwResourceExtent(resource, options.connector);
|
|
5133
|
+
return fetchNgwResourceExtent(resource, options.connector, options);
|
|
5101
5134
|
}
|
|
5102
5135
|
});
|
|
5103
5136
|
}
|
|
5104
5137
|
/** @deprecated use {@link fetchNgwExtent} instead */
|
|
5105
|
-
function fetchNgwResourceExtent(item, connector) {
|
|
5138
|
+
function fetchNgwResourceExtent(item, connector, options) {
|
|
5106
5139
|
if (item.webmap) {
|
|
5107
5140
|
return CancelablePromise.resolve(getNgwWebmapExtent(item.webmap));
|
|
5108
5141
|
}
|
|
@@ -5111,15 +5144,12 @@ function fetchNgwResourceExtent(item, connector) {
|
|
|
5111
5144
|
if (resource.cls && resource.cls.indexOf('style') !== -1) {
|
|
5112
5145
|
return connector.getResource(resource.parent.id).then(function (res) {
|
|
5113
5146
|
if (res) {
|
|
5114
|
-
return fetchNgwLayerExtent({
|
|
5115
|
-
resourceId: res.resource.id,
|
|
5116
|
-
connector: connector,
|
|
5117
|
-
});
|
|
5147
|
+
return fetchNgwLayerExtent(__assign(__assign({}, options), { resourceId: res.resource.id, connector: connector }));
|
|
5118
5148
|
}
|
|
5119
5149
|
});
|
|
5120
5150
|
}
|
|
5121
5151
|
else {
|
|
5122
|
-
return fetchNgwLayerExtent({ resourceId: resource.id, connector: connector });
|
|
5152
|
+
return fetchNgwLayerExtent(__assign(__assign({}, options), { resourceId: resource.id, connector: connector }));
|
|
5123
5153
|
}
|
|
5124
5154
|
}
|
|
5125
5155
|
}
|
|
@@ -5290,7 +5320,7 @@ function createWktFromCoordArray(coord) {
|
|
|
5290
5320
|
}
|
|
5291
5321
|
function fetchNgwLayerItemsRequest(options) {
|
|
5292
5322
|
var params = __assign({}, FEATURE_REQUEST_PARAMS);
|
|
5293
|
-
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;
|
|
5294
5324
|
if (limit) {
|
|
5295
5325
|
if (limit !== Number.POSITIVE_INFINITY) {
|
|
5296
5326
|
params.limit = limit;
|
|
@@ -5320,7 +5350,7 @@ function fetchNgwLayerItemsRequest(options) {
|
|
|
5320
5350
|
params.paramList = paramList;
|
|
5321
5351
|
}
|
|
5322
5352
|
var reqParams = __assign({ id: resourceId }, params);
|
|
5323
|
-
return connector.get('feature_layer.feature.collection', { cache:
|
|
5353
|
+
return connector.get('feature_layer.feature.collection', { cache: cache, signal: signal }, reqParams);
|
|
5324
5354
|
}
|
|
5325
5355
|
|
|
5326
5356
|
function prepareNgwFieldsToPropertiesFilter(fields) {
|
|
@@ -5343,6 +5373,9 @@ function prepareNgwFieldsToPropertiesFilter(fields) {
|
|
|
5343
5373
|
fields[f] = new (Date.bind.apply(Date, __spreadArray([void 0], dt_1, false)))().toISOString();
|
|
5344
5374
|
}
|
|
5345
5375
|
}
|
|
5376
|
+
else if (f === 'id' && typeof field === 'string') {
|
|
5377
|
+
fields[f] = field.split(',').map(Number);
|
|
5378
|
+
}
|
|
5346
5379
|
};
|
|
5347
5380
|
for (f in fields) {
|
|
5348
5381
|
_loop_1();
|
|
@@ -5355,7 +5388,7 @@ function fetchNgwLayerItems(options) {
|
|
|
5355
5388
|
if (filters) {
|
|
5356
5389
|
return createFeatureFieldFilterQueries(__assign(__assign({}, options), { filters: filters })).then(function (data) {
|
|
5357
5390
|
var _a;
|
|
5358
|
-
var clientFilterValidate = (_a = options.clientFilterValidate) !== null && _a !== void 0 ? _a :
|
|
5391
|
+
var clientFilterValidate = (_a = options.clientFilterValidate) !== null && _a !== void 0 ? _a : isFilterWithAnyCase(filters);
|
|
5359
5392
|
// Additional client-side filter check
|
|
5360
5393
|
if (clientFilterValidate) {
|
|
5361
5394
|
data = data.filter(function (y) {
|
|
@@ -5370,6 +5403,21 @@ function fetchNgwLayerItems(options) {
|
|
|
5370
5403
|
else {
|
|
5371
5404
|
return fetchNgwLayerItemsRequest(options);
|
|
5372
5405
|
}
|
|
5406
|
+
}
|
|
5407
|
+
function isFilterWithAnyCase(filters) {
|
|
5408
|
+
if (filters[0] === 'any') {
|
|
5409
|
+
return true;
|
|
5410
|
+
}
|
|
5411
|
+
for (var i = 1; i < filters.length; i++) {
|
|
5412
|
+
var p = filters[i];
|
|
5413
|
+
if (isArray(p)) {
|
|
5414
|
+
var deep = isFilterWithAnyCase(p);
|
|
5415
|
+
if (deep) {
|
|
5416
|
+
return true;
|
|
5417
|
+
}
|
|
5418
|
+
}
|
|
5419
|
+
}
|
|
5420
|
+
return false;
|
|
5373
5421
|
}
|
|
5374
5422
|
|
|
5375
5423
|
function fetchNgwLayerFeatures(options) {
|
|
@@ -7314,7 +7362,7 @@ var NgwResource = /** @class */ (function () {
|
|
|
7314
7362
|
});
|
|
7315
7363
|
});
|
|
7316
7364
|
};
|
|
7317
|
-
NgwResource.prototype.getBounds = function () {
|
|
7365
|
+
NgwResource.prototype.getBounds = function (options) {
|
|
7318
7366
|
return __awaiter(this, void 0, void 0, function () {
|
|
7319
7367
|
var _a;
|
|
7320
7368
|
return __generator(this, function (_b) {
|
|
@@ -7325,7 +7373,7 @@ var NgwResource = /** @class */ (function () {
|
|
|
7325
7373
|
}
|
|
7326
7374
|
if (!this.item) return [3 /*break*/, 2];
|
|
7327
7375
|
_a = this;
|
|
7328
|
-
return [4 /*yield*/, fetchNgwResourceExtent(this.item, this.connector)];
|
|
7376
|
+
return [4 /*yield*/, fetchNgwResourceExtent(this.item, this.connector, options)];
|
|
7329
7377
|
case 1:
|
|
7330
7378
|
_a._extent = _b.sent();
|
|
7331
7379
|
return [2 /*return*/, this._extent];
|
|
@@ -7919,7 +7967,6 @@ function fetchNgwLayerFeature(options) {
|
|
|
7919
7967
|
|
|
7920
7968
|
function getIdentifyItems(identify, multiple) {
|
|
7921
7969
|
if (multiple === void 0) { multiple = false; }
|
|
7922
|
-
var params;
|
|
7923
7970
|
var resources = [];
|
|
7924
7971
|
var paramsList = [];
|
|
7925
7972
|
for (var l in identify) {
|
|
@@ -7940,14 +7987,9 @@ function getIdentifyItems(identify, multiple) {
|
|
|
7940
7987
|
if ('features' in identifyItem) {
|
|
7941
7988
|
var layerFeatures = identifyItem.features;
|
|
7942
7989
|
var resourceId = Number(l);
|
|
7943
|
-
var
|
|
7944
|
-
if (
|
|
7945
|
-
|
|
7946
|
-
featureId: feature.id,
|
|
7947
|
-
resourceId: resourceId,
|
|
7948
|
-
feature: feature,
|
|
7949
|
-
};
|
|
7950
|
-
paramsList.push(params);
|
|
7990
|
+
var featureParams = createParamsFromFeatures(layerFeatures, resourceId, multiple);
|
|
7991
|
+
if (featureParams.length) {
|
|
7992
|
+
paramsList.push.apply(paramsList, featureParams);
|
|
7951
7993
|
if (!multiple) {
|
|
7952
7994
|
break;
|
|
7953
7995
|
}
|
|
@@ -7956,8 +7998,24 @@ function getIdentifyItems(identify, multiple) {
|
|
|
7956
7998
|
}
|
|
7957
7999
|
return paramsList;
|
|
7958
8000
|
}
|
|
8001
|
+
function createParamsFromFeatures(features, resourceId, multiple) {
|
|
8002
|
+
var featureParams = [];
|
|
8003
|
+
for (var _i = 0, features_1 = features; _i < features_1.length; _i++) {
|
|
8004
|
+
var feature = features_1[_i];
|
|
8005
|
+
var params = {
|
|
8006
|
+
featureId: feature.id,
|
|
8007
|
+
resourceId: resourceId,
|
|
8008
|
+
feature: feature,
|
|
8009
|
+
};
|
|
8010
|
+
featureParams.push(params);
|
|
8011
|
+
if (!multiple) {
|
|
8012
|
+
break;
|
|
8013
|
+
}
|
|
8014
|
+
}
|
|
8015
|
+
return featureParams;
|
|
8016
|
+
}
|
|
7959
8017
|
function fetchIdentifyGeoJson(options) {
|
|
7960
|
-
var connector = options.connector, identify = options.identify;
|
|
8018
|
+
var connector = options.connector, identify = options.identify, requestOptions = options.requestOptions;
|
|
7961
8019
|
for (var l in identify) {
|
|
7962
8020
|
var id = Number(l);
|
|
7963
8021
|
if (!isNaN(id)) {
|
|
@@ -7973,7 +8031,7 @@ function fetchIdentifyGeoJson(options) {
|
|
|
7973
8031
|
}
|
|
7974
8032
|
var params = getIdentifyItems(identify);
|
|
7975
8033
|
if (params && params.length) {
|
|
7976
|
-
return fetchNgwLayerFeature(__assign({ connector: connector }, params[0]));
|
|
8034
|
+
return fetchNgwLayerFeature(__assign(__assign(__assign({}, requestOptions), { connector: connector }), params[0]));
|
|
7977
8035
|
}
|
|
7978
8036
|
return CancelablePromise.resolve(undefined);
|
|
7979
8037
|
}
|
|
@@ -7986,21 +8044,25 @@ function fetchIdentifyItem(options) {
|
|
|
7986
8044
|
return CancelablePromise.resolve(undefined);
|
|
7987
8045
|
}
|
|
7988
8046
|
function featureLayerIdentify(options) {
|
|
7989
|
-
var
|
|
7990
|
-
var
|
|
7991
|
-
if (Array.isArray(
|
|
7992
|
-
|
|
8047
|
+
var geom = options.geom, signal = options.signal, cache = options.cache;
|
|
8048
|
+
var geom_ = [];
|
|
8049
|
+
if (Array.isArray(geom)) {
|
|
8050
|
+
geom_ = geom;
|
|
7993
8051
|
}
|
|
7994
8052
|
else {
|
|
7995
|
-
var polygon =
|
|
8053
|
+
var polygon = geom.type === 'Feature'
|
|
8054
|
+
? geom.geometry
|
|
8055
|
+
: geom.type === 'Polygon'
|
|
8056
|
+
? geom
|
|
8057
|
+
: false;
|
|
7996
8058
|
if (polygon) {
|
|
7997
|
-
|
|
8059
|
+
geom_ = polygon.coordinates[0];
|
|
7998
8060
|
}
|
|
7999
8061
|
}
|
|
8000
|
-
if (
|
|
8062
|
+
if (geom_) {
|
|
8001
8063
|
// create wkt string
|
|
8002
8064
|
var polygonStr = [];
|
|
8003
|
-
for (var _i = 0, geom_1 =
|
|
8065
|
+
for (var _i = 0, geom_1 = geom_; _i < geom_1.length; _i++) {
|
|
8004
8066
|
var _a = geom_1[_i], lng = _a[0], lat = _a[1];
|
|
8005
8067
|
var _b = degrees2meters(lng, lat), x = _b[0], y = _b[1];
|
|
8006
8068
|
polygonStr.push(x + ' ' + y);
|
|
@@ -8012,18 +8074,22 @@ function featureLayerIdentify(options) {
|
|
|
8012
8074
|
srs: 3857,
|
|
8013
8075
|
layers: layers,
|
|
8014
8076
|
};
|
|
8015
|
-
return options.connector.post('feature_layer.identify', {
|
|
8077
|
+
return options.connector.post('feature_layer.identify', {
|
|
8078
|
+
data: data,
|
|
8079
|
+
signal: signal,
|
|
8080
|
+
cache: cache,
|
|
8081
|
+
});
|
|
8016
8082
|
}
|
|
8017
8083
|
else {
|
|
8018
8084
|
throw new Error('Not valid geometry format to make intersection');
|
|
8019
8085
|
}
|
|
8020
8086
|
}
|
|
8021
8087
|
function sendIdentifyRequest(ev, options) {
|
|
8022
|
-
var _a;
|
|
8023
8088
|
deprecatedMapClick(ev);
|
|
8024
|
-
var
|
|
8025
|
-
var geom =
|
|
8026
|
-
|
|
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 }));
|
|
8027
8093
|
}
|
|
8028
8094
|
function createIdentifyItem(opt) {
|
|
8029
8095
|
return new IdentifyItem(opt);
|