@nextgis/ngw-map 1.14.0 → 1.16.0
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/lib/index.d.ts +0 -6
- package/lib/ngw-map.cjs.js +2 -2
- package/lib/ngw-map.cjs.js.map +1 -1
- package/lib/ngw-map.cjs.prod.js +1 -1
- package/lib/ngw-map.cjs.prod.js.map +1 -1
- package/lib/ngw-map.esm-browser.js +84 -62
- package/lib/ngw-map.esm-browser.js.map +1 -1
- package/lib/ngw-map.esm-browser.prod.js +1 -15
- package/lib/ngw-map.esm-browser.prod.js.map +1 -1
- package/lib/ngw-map.esm-bundler.js +2 -2
- package/lib/ngw-map.esm-bundler.js.map +1 -1
- package/lib/ngw-map.esm-bundler.prod.js +1 -15
- package/lib/ngw-map.esm-bundler.prod.js.map +1 -1
- package/lib/ngw-map.global.js +84 -62
- package/lib/ngw-map.global.js.map +1 -1
- package/lib/ngw-map.global.prod.js +1 -15
- package/lib/ngw-map.global.prod.js.map +1 -1
- package/package.json +9 -9
package/lib/ngw-map.global.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/** Bundle of @nextgis/ngw-map; version: 1.
|
|
1
|
+
/** Bundle of @nextgis/ngw-map; version: 1.16.0; author: NextGIS */
|
|
2
2
|
var NgwMap = (function (exports) {
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
/******************************************************************************
|
|
6
6
|
Copyright (c) Microsoft Corporation.
|
|
7
7
|
|
|
8
8
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -1525,6 +1525,24 @@ var NgwMap = (function (exports) {
|
|
|
1525
1525
|
return mask;
|
|
1526
1526
|
};
|
|
1527
1527
|
}
|
|
1528
|
+
function expressionCallback(paint, defaultPaint, getPaintFunctions) {
|
|
1529
|
+
var expressionCallback = createExpressionCallback(paint);
|
|
1530
|
+
if (expressionCallback) {
|
|
1531
|
+
var expressionPaintCb = function (feature) {
|
|
1532
|
+
return preparePaint(expressionCallback(feature), defaultPaint, getPaintFunctions);
|
|
1533
|
+
};
|
|
1534
|
+
expressionPaintCb.paint = paint;
|
|
1535
|
+
return expressionPaintCb;
|
|
1536
|
+
}
|
|
1537
|
+
var newPaint = __assign({}, defaultPaint);
|
|
1538
|
+
newPaint = __assign(__assign({}, newPaint), paint);
|
|
1539
|
+
newPaint.fill = newPaint.fill !== undefined ? newPaint.fill : true;
|
|
1540
|
+
newPaint.stroke =
|
|
1541
|
+
newPaint.stroke !== undefined
|
|
1542
|
+
? newPaint.stroke
|
|
1543
|
+
: !newPaint.fill || !!(newPaint.strokeColor || newPaint.strokeOpacity);
|
|
1544
|
+
return newPaint;
|
|
1545
|
+
}
|
|
1528
1546
|
function preparePaint(paint, defaultPaint, getPaintFunctions) {
|
|
1529
1547
|
if (!paint) {
|
|
1530
1548
|
throw new Error('paint is empty');
|
|
@@ -1554,20 +1572,7 @@ var NgwMap = (function (exports) {
|
|
|
1554
1572
|
return paint;
|
|
1555
1573
|
}
|
|
1556
1574
|
else {
|
|
1557
|
-
|
|
1558
|
-
if (expressionCallback_1) {
|
|
1559
|
-
var expressionPaintCb = function (feature) {
|
|
1560
|
-
return preparePaint(expressionCallback_1(feature), defaultPaint, getPaintFunctions);
|
|
1561
|
-
};
|
|
1562
|
-
expressionPaintCb.paint = paint;
|
|
1563
|
-
return expressionPaintCb;
|
|
1564
|
-
}
|
|
1565
|
-
newPaint = __assign(__assign({}, newPaint), paint);
|
|
1566
|
-
newPaint.fill = newPaint.fill !== undefined ? newPaint.fill : true;
|
|
1567
|
-
newPaint.stroke =
|
|
1568
|
-
newPaint.stroke !== undefined
|
|
1569
|
-
? newPaint.stroke
|
|
1570
|
-
: !newPaint.fill || !!(newPaint.strokeColor || newPaint.strokeOpacity);
|
|
1575
|
+
newPaint = expressionCallback(paint, defaultPaint, getPaintFunctions);
|
|
1571
1576
|
}
|
|
1572
1577
|
if (isPaintCallback(newPaint)) {
|
|
1573
1578
|
return newPaint;
|
|
@@ -4440,6 +4445,29 @@ var NgwMap = (function (exports) {
|
|
|
4440
4445
|
return _this._getChildrenOf(parent, requestOptions);
|
|
4441
4446
|
});
|
|
4442
4447
|
};
|
|
4448
|
+
ResourcesControl.prototype.update = function (resource, data) {
|
|
4449
|
+
var _this = this;
|
|
4450
|
+
return this.getId(resource).then(function (id) {
|
|
4451
|
+
if (id !== undefined) {
|
|
4452
|
+
return _this.connector.put('resource.item', { data: data }, { id: id });
|
|
4453
|
+
}
|
|
4454
|
+
});
|
|
4455
|
+
};
|
|
4456
|
+
/**
|
|
4457
|
+
* Fast way to delete resource from NGW and clean cache.
|
|
4458
|
+
* @param resource - Resource definition
|
|
4459
|
+
*/
|
|
4460
|
+
ResourcesControl.prototype.delete = function (resource) {
|
|
4461
|
+
var _this = this;
|
|
4462
|
+
return this.getId(resource).then(function (id) {
|
|
4463
|
+
if (id !== undefined) {
|
|
4464
|
+
return _this.connector.delete('resource.item', null, { id: id }).then(function () {
|
|
4465
|
+
_this._cleanResourceItemCache(id);
|
|
4466
|
+
return undefined;
|
|
4467
|
+
});
|
|
4468
|
+
}
|
|
4469
|
+
});
|
|
4470
|
+
};
|
|
4443
4471
|
ResourcesControl.prototype._getChildrenOf = function (parent, requestOptions, _items) {
|
|
4444
4472
|
var _this = this;
|
|
4445
4473
|
if (_items === void 0) { _items = []; }
|
|
@@ -4467,29 +4495,6 @@ var NgwMap = (function (exports) {
|
|
|
4467
4495
|
return _items;
|
|
4468
4496
|
});
|
|
4469
4497
|
};
|
|
4470
|
-
ResourcesControl.prototype.update = function (resource, data) {
|
|
4471
|
-
var _this = this;
|
|
4472
|
-
return this.getId(resource).then(function (id) {
|
|
4473
|
-
if (id !== undefined) {
|
|
4474
|
-
return _this.connector.put('resource.item', { data: data }, { id: id });
|
|
4475
|
-
}
|
|
4476
|
-
});
|
|
4477
|
-
};
|
|
4478
|
-
/**
|
|
4479
|
-
* Fast way to delete resource from NGW and clean cache.
|
|
4480
|
-
* @param resource - Resource definition
|
|
4481
|
-
*/
|
|
4482
|
-
ResourcesControl.prototype.delete = function (resource) {
|
|
4483
|
-
var _this = this;
|
|
4484
|
-
return this.getId(resource).then(function (id) {
|
|
4485
|
-
if (id !== undefined) {
|
|
4486
|
-
return _this.connector.delete('resource.item', null, { id: id }).then(function () {
|
|
4487
|
-
_this._cleanResourceItemCache(id);
|
|
4488
|
-
return undefined;
|
|
4489
|
-
});
|
|
4490
|
-
}
|
|
4491
|
-
});
|
|
4492
|
-
};
|
|
4493
4498
|
ResourcesControl.prototype._cleanResourceItemCache = function (id) {
|
|
4494
4499
|
return __awaiter(this, void 0, void 0, function () {
|
|
4495
4500
|
var all, toDelete, _i, all_1, c, cid, rid, _a, toDelete_1, d;
|
|
@@ -4647,6 +4652,9 @@ var NgwMap = (function (exports) {
|
|
|
4647
4652
|
if (this.options.route) {
|
|
4648
4653
|
this.routeStr = this.options.route;
|
|
4649
4654
|
}
|
|
4655
|
+
if (this.options.requestTransform) {
|
|
4656
|
+
this.requestTransform = this.options.requestTransform;
|
|
4657
|
+
}
|
|
4650
4658
|
this.resources = new ResourcesControl(this);
|
|
4651
4659
|
addConnector(this);
|
|
4652
4660
|
}
|
|
@@ -4654,6 +4662,9 @@ var NgwMap = (function (exports) {
|
|
|
4654
4662
|
NgwConnector.create = function (options) {
|
|
4655
4663
|
return new this(options);
|
|
4656
4664
|
};
|
|
4665
|
+
NgwConnector.prototype.setRequestTransform = function (requestTransform) {
|
|
4666
|
+
this.requestTransform = requestTransform;
|
|
4667
|
+
};
|
|
4657
4668
|
/**
|
|
4658
4669
|
* Fast way to specify the connection address to NextGIS Web.
|
|
4659
4670
|
* The current connection will be severed.
|
|
@@ -4913,9 +4924,8 @@ var NgwMap = (function (exports) {
|
|
|
4913
4924
|
if (params) {
|
|
4914
4925
|
url = template(url, params);
|
|
4915
4926
|
}
|
|
4916
|
-
|
|
4917
|
-
|
|
4918
|
-
return this._loadData(encodeURI(url), options);
|
|
4927
|
+
url = encodeURI(fixUrlStr(url));
|
|
4928
|
+
return this._loadData(url, options);
|
|
4919
4929
|
}
|
|
4920
4930
|
else {
|
|
4921
4931
|
throw new Error('Empty `url` not allowed');
|
|
@@ -5008,6 +5018,11 @@ var NgwMap = (function (exports) {
|
|
|
5008
5018
|
// options.withCredentials = true;
|
|
5009
5019
|
options.headers = __assign(__assign({}, _this.getAuthorizationHeaders()), options.headers);
|
|
5010
5020
|
}
|
|
5021
|
+
if (_this.requestTransform) {
|
|
5022
|
+
var _a = _this.requestTransform(url, options), transUrl = _a[0], transOptions = _a[1];
|
|
5023
|
+
url = transUrl;
|
|
5024
|
+
options = transOptions;
|
|
5025
|
+
}
|
|
5011
5026
|
loadData(url, resolve, options, reject, onCancel);
|
|
5012
5027
|
})
|
|
5013
5028
|
.then(function (resp) {
|
|
@@ -5032,6 +5047,7 @@ var NgwMap = (function (exports) {
|
|
|
5032
5047
|
typeof options.signal.addEventListener === 'function') {
|
|
5033
5048
|
options.signal.addEventListener('abort', function () {
|
|
5034
5049
|
request.cancel();
|
|
5050
|
+
_this._cleanActiveRequests(request);
|
|
5035
5051
|
});
|
|
5036
5052
|
}
|
|
5037
5053
|
this.activeRequests.push(request);
|
|
@@ -6634,10 +6650,12 @@ var NgwMap = (function (exports) {
|
|
|
6634
6650
|
};
|
|
6635
6651
|
if (item.item_type === 'group' || item.item_type === 'root') {
|
|
6636
6652
|
if (item.children && item.children.length) {
|
|
6637
|
-
this.getChildren(item)
|
|
6638
|
-
|
|
6639
|
-
|
|
6640
|
-
|
|
6653
|
+
var children = this.getChildren(item);
|
|
6654
|
+
for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
|
|
6655
|
+
var x = children_1[_i];
|
|
6656
|
+
var children_2 = new this.constructor(this.webMap, x, this.options, this.connector, this);
|
|
6657
|
+
this.tree.addChild(children_2);
|
|
6658
|
+
}
|
|
6641
6659
|
}
|
|
6642
6660
|
return Promise.resolve();
|
|
6643
6661
|
}
|
|
@@ -6678,7 +6696,7 @@ var NgwMap = (function (exports) {
|
|
|
6678
6696
|
headers: this.options.headers,
|
|
6679
6697
|
crossOrigin: this.options.crossOrigin,
|
|
6680
6698
|
setViewDelay: this.options.setViewDelay,
|
|
6681
|
-
params: { resource: this.item.resourceId },
|
|
6699
|
+
params: { resource: this.item.resourceId, item: this.item },
|
|
6682
6700
|
};
|
|
6683
6701
|
if (this.options.order) {
|
|
6684
6702
|
var subOrder = this.options.drawOrderEnabled && 'draw_order_position' in item
|
|
@@ -6689,6 +6707,9 @@ var NgwMap = (function (exports) {
|
|
|
6689
6707
|
var subLevel = String(subOrder).padStart(4, '0');
|
|
6690
6708
|
options.order = Number((this.options.order | 0) + '.' + subLevel);
|
|
6691
6709
|
}
|
|
6710
|
+
if (this.options.popupOptions) {
|
|
6711
|
+
options.popupOptions = this.options.popupOptions;
|
|
6712
|
+
}
|
|
6692
6713
|
if (item.item_type === 'layer') {
|
|
6693
6714
|
var _a = this._getZoomRange(item), maxZoom = _a.maxZoom, minZoom = _a.minZoom;
|
|
6694
6715
|
objectAssign(options, {
|
|
@@ -6736,8 +6757,8 @@ var NgwMap = (function (exports) {
|
|
|
6736
6757
|
};
|
|
6737
6758
|
NgwWebmapItem.prototype._sumUp = function (children, totalValue) {
|
|
6738
6759
|
if (totalValue === void 0) { totalValue = 0; }
|
|
6739
|
-
for (var _i = 0,
|
|
6740
|
-
var child =
|
|
6760
|
+
for (var _i = 0, children_3 = children; _i < children_3.length; _i++) {
|
|
6761
|
+
var child = children_3[_i];
|
|
6741
6762
|
if (child.item_type === 'layer') {
|
|
6742
6763
|
totalValue += 1;
|
|
6743
6764
|
child.draw_order_position = child.draw_order_position || totalValue;
|
|
@@ -7044,8 +7065,6 @@ var NgwMap = (function (exports) {
|
|
|
7044
7065
|
this._extent &&
|
|
7045
7066
|
extentConstrained) {
|
|
7046
7067
|
this.options.webMap.setView({ maxBounds: this._extent });
|
|
7047
|
-
// @ts-ignore
|
|
7048
|
-
window.webmap = this.options.webMap;
|
|
7049
7068
|
}
|
|
7050
7069
|
return [2 /*return*/, this.layer];
|
|
7051
7070
|
}
|
|
@@ -7218,6 +7237,7 @@ var NgwMap = (function (exports) {
|
|
|
7218
7237
|
options.minZoom = _this.options.minZoom;
|
|
7219
7238
|
options.maxZoom = _this.options.maxZoom;
|
|
7220
7239
|
options.drawOrderEnabled = webmap_1.draw_order_enabled;
|
|
7240
|
+
options.popupOptions = _this.options.popupOptions;
|
|
7221
7241
|
var layer = new _this.NgwWebmapItem(_this.options.webMap, webmap_1.root_item, options, _this.options.connector);
|
|
7222
7242
|
layer.emitter.on('init', function () { return resolve(layer); });
|
|
7223
7243
|
})];
|
|
@@ -7348,30 +7368,34 @@ var NgwMap = (function (exports) {
|
|
|
7348
7368
|
};
|
|
7349
7369
|
NgwWebmapLayerAdapter.prototype._getWebMapIds = function () {
|
|
7350
7370
|
return __awaiter(this, void 0, void 0, function () {
|
|
7351
|
-
var webMapItem, layers,
|
|
7352
|
-
var _this = this;
|
|
7371
|
+
var webMapItem, layers, promises, _loop_2, this_2, _i, layers_1, x, ids;
|
|
7353
7372
|
return __generator(this, function (_a) {
|
|
7354
7373
|
switch (_a.label) {
|
|
7355
7374
|
case 0:
|
|
7356
7375
|
webMapItem = this.layer;
|
|
7357
7376
|
if (!(webMapItem && webMapItem.item.item_type === 'root')) return [3 /*break*/, 2];
|
|
7358
7377
|
layers = webMapItem.tree.getDescendants();
|
|
7359
|
-
|
|
7360
|
-
|
|
7378
|
+
promises = [];
|
|
7379
|
+
_loop_2 = function (x) {
|
|
7361
7380
|
var item = x.item;
|
|
7362
7381
|
if (item.item_type === 'layer') {
|
|
7363
7382
|
var id = item.layer_style_id;
|
|
7364
|
-
var promise =
|
|
7383
|
+
var promise = this_2.options.connector.getResource(id).then(function (y) {
|
|
7365
7384
|
if (y) {
|
|
7366
7385
|
var parentId = Number(y.resource.parent.id);
|
|
7367
7386
|
item.parentId = parentId;
|
|
7368
7387
|
return parentId;
|
|
7369
7388
|
}
|
|
7370
7389
|
});
|
|
7371
|
-
|
|
7390
|
+
promises.push(promise);
|
|
7372
7391
|
}
|
|
7373
|
-
}
|
|
7374
|
-
|
|
7392
|
+
};
|
|
7393
|
+
this_2 = this;
|
|
7394
|
+
for (_i = 0, layers_1 = layers; _i < layers_1.length; _i++) {
|
|
7395
|
+
x = layers_1[_i];
|
|
7396
|
+
_loop_2(x);
|
|
7397
|
+
}
|
|
7398
|
+
return [4 /*yield*/, Promise.all(promises)];
|
|
7375
7399
|
case 1:
|
|
7376
7400
|
ids = _a.sent();
|
|
7377
7401
|
return [2 /*return*/, ids.filter(function (x) { return x !== undefined; })];
|
|
@@ -7787,10 +7811,8 @@ var NgwMap = (function (exports) {
|
|
|
7787
7811
|
var A = /** @class */ (function (_super) {
|
|
7788
7812
|
__extends(A, _super);
|
|
7789
7813
|
function A(map, options) {
|
|
7790
|
-
var _this = this;
|
|
7791
7814
|
options = __assign(__assign({}, opt), options);
|
|
7792
|
-
|
|
7793
|
-
return _this;
|
|
7815
|
+
return _super.call(this, map, options) || this;
|
|
7794
7816
|
}
|
|
7795
7817
|
return A;
|
|
7796
7818
|
}(NgwWebmapLayerAdapter));
|