@nextgis/ngw-leaflet 1.12.1 → 1.13.5
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/ngw-leaflet.esm-browser.js +84 -50
- package/lib/ngw-leaflet.esm-browser.js.map +1 -1
- package/lib/ngw-leaflet.esm-browser.prod.js +2 -2
- package/lib/ngw-leaflet.esm-browser.prod.js.map +1 -1
- package/lib/ngw-leaflet.esm-bundler.js +1 -1
- package/lib/ngw-leaflet.global.js +84 -50
- package/lib/ngw-leaflet.global.js.map +1 -1
- package/lib/ngw-leaflet.global.prod.js +2 -2
- package/lib/ngw-leaflet.global.prod.js.map +1 -1
- package/package.json +4 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Bundle of @nextgis/ngw-leaflet; version: 1.
|
|
1
|
+
/** Bundle of @nextgis/ngw-leaflet; version: 1.13.5; author: NextGIS */
|
|
2
2
|
/*! *****************************************************************************
|
|
3
3
|
Copyright (c) Microsoft Corporation.
|
|
4
4
|
|
|
@@ -18116,31 +18116,31 @@ var Cache = /** @class */ (function () {
|
|
|
18116
18116
|
/**
|
|
18117
18117
|
* Thrown when...
|
|
18118
18118
|
*/
|
|
18119
|
-
var
|
|
18120
|
-
__extends(
|
|
18121
|
-
function
|
|
18119
|
+
var NetworkError = /** @class */ (function (_super) {
|
|
18120
|
+
__extends(NetworkError, _super);
|
|
18121
|
+
function NetworkError(url) {
|
|
18122
18122
|
var _this = _super.call(this) || this;
|
|
18123
|
-
_this.name = '
|
|
18124
|
-
Object.
|
|
18125
|
-
|
|
18123
|
+
_this.name = 'NetworkError';
|
|
18124
|
+
Object.setPrototypeOf(_this, NetworkError.prototype);
|
|
18125
|
+
_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
|
|
18126
18126
|
return _this;
|
|
18127
18127
|
}
|
|
18128
|
-
return
|
|
18128
|
+
return NetworkError;
|
|
18129
18129
|
}(Error));
|
|
18130
18130
|
|
|
18131
18131
|
/**
|
|
18132
18132
|
* Thrown when...
|
|
18133
18133
|
*/
|
|
18134
|
-
var
|
|
18135
|
-
__extends(
|
|
18136
|
-
function
|
|
18134
|
+
var NgwError = /** @class */ (function (_super) {
|
|
18135
|
+
__extends(NgwError, _super);
|
|
18136
|
+
function NgwError(er) {
|
|
18137
18137
|
var _this = _super.call(this) || this;
|
|
18138
|
-
_this.name = '
|
|
18139
|
-
Object.
|
|
18140
|
-
|
|
18138
|
+
_this.name = 'NgwError';
|
|
18139
|
+
Object.assign(_this, er);
|
|
18140
|
+
Object.setPrototypeOf(_this, NgwError.prototype);
|
|
18141
18141
|
return _this;
|
|
18142
18142
|
}
|
|
18143
|
-
return
|
|
18143
|
+
return NgwError;
|
|
18144
18144
|
}(Error));
|
|
18145
18145
|
|
|
18146
18146
|
function isObject(val) {
|
|
@@ -18254,11 +18254,6 @@ var loadData;
|
|
|
18254
18254
|
xhr.abort();
|
|
18255
18255
|
});
|
|
18256
18256
|
}
|
|
18257
|
-
if (options.signal) {
|
|
18258
|
-
options.signal.addEventListener('abort', function () {
|
|
18259
|
-
xhr.abort();
|
|
18260
|
-
});
|
|
18261
|
-
}
|
|
18262
18257
|
xhr.send(data);
|
|
18263
18258
|
};
|
|
18264
18259
|
}
|
|
@@ -18709,6 +18704,7 @@ var NgwConnector = /** @class */ (function () {
|
|
|
18709
18704
|
this.id = ID$1++;
|
|
18710
18705
|
this.emitter = new events.exports.EventEmitter();
|
|
18711
18706
|
this.routeStr = '/api/component/pyramid/route';
|
|
18707
|
+
this.activeRequests = [];
|
|
18712
18708
|
var exist = findConnector(options);
|
|
18713
18709
|
if (exist) {
|
|
18714
18710
|
return exist;
|
|
@@ -18794,6 +18790,7 @@ var NgwConnector = /** @class */ (function () {
|
|
|
18794
18790
|
* Disconnecting a user. Aborting all current requests
|
|
18795
18791
|
*/
|
|
18796
18792
|
NgwConnector.prototype.logout = function () {
|
|
18793
|
+
this.abort();
|
|
18797
18794
|
removeConnector(this);
|
|
18798
18795
|
this.options.auth = undefined;
|
|
18799
18796
|
this.user = undefined;
|
|
@@ -18846,6 +18843,17 @@ var NgwConnector = /** @class */ (function () {
|
|
|
18846
18843
|
}
|
|
18847
18844
|
}
|
|
18848
18845
|
};
|
|
18846
|
+
/** Stop all api requests */
|
|
18847
|
+
NgwConnector.prototype.abort = function () {
|
|
18848
|
+
for (var _i = 0, _a = this.activeRequests; _i < _a.length; _i++) {
|
|
18849
|
+
var req = _a[_i];
|
|
18850
|
+
req.cancel();
|
|
18851
|
+
}
|
|
18852
|
+
this.activeRequests = [];
|
|
18853
|
+
};
|
|
18854
|
+
NgwConnector.prototype.getActiveApiRequests = function () {
|
|
18855
|
+
return __spreadArray([], this.activeRequests, true);
|
|
18856
|
+
};
|
|
18849
18857
|
/**
|
|
18850
18858
|
* Send request to NGW api router.
|
|
18851
18859
|
* @param name - NGW route name from {@link https://docs.nextgis.com/docs_ngweb_dev/doc/developer/resource.html#routes | routes}
|
|
@@ -19060,14 +19068,20 @@ var NgwConnector = /** @class */ (function () {
|
|
|
19060
19068
|
NgwConnector.prototype._loadData = function (url, options) {
|
|
19061
19069
|
var _this = this;
|
|
19062
19070
|
options.responseType = options.responseType || 'json';
|
|
19063
|
-
|
|
19071
|
+
var request = new CancelablePromise(function (resolve, reject, onCancel) {
|
|
19064
19072
|
if (_this.user) {
|
|
19065
19073
|
options = options || {};
|
|
19066
19074
|
// options.withCredentials = true;
|
|
19067
19075
|
options.headers = __assign(__assign({}, _this.getAuthorizationHeaders()), options.headers);
|
|
19068
19076
|
}
|
|
19069
19077
|
loadData(url, resolve, options, reject, onCancel);
|
|
19070
|
-
})
|
|
19078
|
+
})
|
|
19079
|
+
.then(function (resp) {
|
|
19080
|
+
_this._cleanActiveRequests(request);
|
|
19081
|
+
return resp;
|
|
19082
|
+
})
|
|
19083
|
+
.catch(function (httpError) {
|
|
19084
|
+
_this._cleanActiveRequests(request);
|
|
19071
19085
|
if (httpError instanceof CancelablePromise.CancelError) ;
|
|
19072
19086
|
else {
|
|
19073
19087
|
// @ts-ignore
|
|
@@ -19080,6 +19094,20 @@ var NgwConnector = /** @class */ (function () {
|
|
|
19080
19094
|
}
|
|
19081
19095
|
}
|
|
19082
19096
|
});
|
|
19097
|
+
if (options.signal &&
|
|
19098
|
+
typeof options.signal.addEventListener === 'function') {
|
|
19099
|
+
options.signal.addEventListener('abort', function () {
|
|
19100
|
+
request.cancel();
|
|
19101
|
+
});
|
|
19102
|
+
}
|
|
19103
|
+
this.activeRequests.push(request);
|
|
19104
|
+
return request;
|
|
19105
|
+
};
|
|
19106
|
+
NgwConnector.prototype._cleanActiveRequests = function (request) {
|
|
19107
|
+
var activeRequestIndex = this.activeRequests.indexOf(request);
|
|
19108
|
+
if (activeRequestIndex !== -1) {
|
|
19109
|
+
this.activeRequests.splice(activeRequestIndex, 1);
|
|
19110
|
+
}
|
|
19083
19111
|
};
|
|
19084
19112
|
NgwConnector.prototype._handleHttpError = function (er) {
|
|
19085
19113
|
if (er) {
|
|
@@ -19189,12 +19217,12 @@ function fetchNgwLayerItemExtent(_a) {
|
|
|
19189
19217
|
function fetchNgwExtent(options) {
|
|
19190
19218
|
return options.connector.getResource(options.resourceId).then(function (resource) {
|
|
19191
19219
|
if (resource) {
|
|
19192
|
-
return fetchNgwResourceExtent(resource, options.connector);
|
|
19220
|
+
return fetchNgwResourceExtent(resource, options.connector, options);
|
|
19193
19221
|
}
|
|
19194
19222
|
});
|
|
19195
19223
|
}
|
|
19196
19224
|
/** @deprecated use {@link fetchNgwExtent} instead */
|
|
19197
|
-
function fetchNgwResourceExtent(item, connector) {
|
|
19225
|
+
function fetchNgwResourceExtent(item, connector, options) {
|
|
19198
19226
|
if (item.webmap) {
|
|
19199
19227
|
return CancelablePromise.resolve(getNgwWebmapExtent(item.webmap));
|
|
19200
19228
|
}
|
|
@@ -19203,15 +19231,12 @@ function fetchNgwResourceExtent(item, connector) {
|
|
|
19203
19231
|
if (resource.cls && resource.cls.indexOf('style') !== -1) {
|
|
19204
19232
|
return connector.getResource(resource.parent.id).then(function (res) {
|
|
19205
19233
|
if (res) {
|
|
19206
|
-
return fetchNgwLayerExtent({
|
|
19207
|
-
resourceId: res.resource.id,
|
|
19208
|
-
connector: connector,
|
|
19209
|
-
});
|
|
19234
|
+
return fetchNgwLayerExtent(__assign(__assign({}, options), { resourceId: res.resource.id, connector: connector }));
|
|
19210
19235
|
}
|
|
19211
19236
|
});
|
|
19212
19237
|
}
|
|
19213
19238
|
else {
|
|
19214
|
-
return fetchNgwLayerExtent({ resourceId: resource.id, connector: connector });
|
|
19239
|
+
return fetchNgwLayerExtent(__assign(__assign({}, options), { resourceId: resource.id, connector: connector }));
|
|
19215
19240
|
}
|
|
19216
19241
|
}
|
|
19217
19242
|
}
|
|
@@ -19382,7 +19407,7 @@ function createWktFromCoordArray(coord) {
|
|
|
19382
19407
|
}
|
|
19383
19408
|
function fetchNgwLayerItemsRequest(options) {
|
|
19384
19409
|
var params = __assign({}, FEATURE_REQUEST_PARAMS);
|
|
19385
|
-
var limit = options.limit, offset = options.offset, orderBy = options.orderBy, paramList = options.paramList, connector = options.connector, intersects = options.intersects, resourceId = options.resourceId;
|
|
19410
|
+
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;
|
|
19386
19411
|
if (limit) {
|
|
19387
19412
|
if (limit !== Number.POSITIVE_INFINITY) {
|
|
19388
19413
|
params.limit = limit;
|
|
@@ -19412,11 +19437,10 @@ function fetchNgwLayerItemsRequest(options) {
|
|
|
19412
19437
|
params.paramList = paramList;
|
|
19413
19438
|
}
|
|
19414
19439
|
var reqParams = __assign({ id: resourceId }, params);
|
|
19415
|
-
return connector.get('feature_layer.feature.collection', { cache:
|
|
19440
|
+
return connector.get('feature_layer.feature.collection', { cache: cache, signal: signal }, reqParams);
|
|
19416
19441
|
}
|
|
19417
19442
|
|
|
19418
19443
|
function prepareNgwFieldsToPropertiesFilter(fields) {
|
|
19419
|
-
console.log(fields);
|
|
19420
19444
|
var f;
|
|
19421
19445
|
var _loop_1 = function () {
|
|
19422
19446
|
var field = fields[f];
|
|
@@ -21425,7 +21449,7 @@ var NgwResource = /** @class */ (function () {
|
|
|
21425
21449
|
});
|
|
21426
21450
|
});
|
|
21427
21451
|
};
|
|
21428
|
-
NgwResource.prototype.getBounds = function () {
|
|
21452
|
+
NgwResource.prototype.getBounds = function (options) {
|
|
21429
21453
|
return __awaiter(this, void 0, void 0, function () {
|
|
21430
21454
|
var _a;
|
|
21431
21455
|
return __generator(this, function (_b) {
|
|
@@ -21436,7 +21460,7 @@ var NgwResource = /** @class */ (function () {
|
|
|
21436
21460
|
}
|
|
21437
21461
|
if (!this.item) return [3 /*break*/, 2];
|
|
21438
21462
|
_a = this;
|
|
21439
|
-
return [4 /*yield*/, fetchNgwResourceExtent(this.item, this.connector)];
|
|
21463
|
+
return [4 /*yield*/, fetchNgwResourceExtent(this.item, this.connector, options)];
|
|
21440
21464
|
case 1:
|
|
21441
21465
|
_a._extent = _b.sent();
|
|
21442
21466
|
return [2 /*return*/, this._extent];
|
|
@@ -22078,7 +22102,7 @@ function createParamsFromFeatures(features, resourceId, multiple) {
|
|
|
22078
22102
|
return featureParams;
|
|
22079
22103
|
}
|
|
22080
22104
|
function fetchIdentifyGeoJson(options) {
|
|
22081
|
-
var connector = options.connector, identify = options.identify;
|
|
22105
|
+
var connector = options.connector, identify = options.identify, requestOptions = options.requestOptions;
|
|
22082
22106
|
for (var l in identify) {
|
|
22083
22107
|
var id = Number(l);
|
|
22084
22108
|
if (!isNaN(id)) {
|
|
@@ -22094,7 +22118,7 @@ function fetchIdentifyGeoJson(options) {
|
|
|
22094
22118
|
}
|
|
22095
22119
|
var params = getIdentifyItems(identify);
|
|
22096
22120
|
if (params && params.length) {
|
|
22097
|
-
return fetchNgwLayerFeature(__assign({ connector: connector }, params[0]));
|
|
22121
|
+
return fetchNgwLayerFeature(__assign(__assign(__assign({}, requestOptions), { connector: connector }), params[0]));
|
|
22098
22122
|
}
|
|
22099
22123
|
return CancelablePromise.resolve(undefined);
|
|
22100
22124
|
}
|
|
@@ -22107,21 +22131,25 @@ function fetchIdentifyItem(options) {
|
|
|
22107
22131
|
return CancelablePromise.resolve(undefined);
|
|
22108
22132
|
}
|
|
22109
22133
|
function featureLayerIdentify(options) {
|
|
22110
|
-
var
|
|
22111
|
-
var
|
|
22112
|
-
if (Array.isArray(
|
|
22113
|
-
|
|
22134
|
+
var geom = options.geom, signal = options.signal, cache = options.cache;
|
|
22135
|
+
var geom_ = [];
|
|
22136
|
+
if (Array.isArray(geom)) {
|
|
22137
|
+
geom_ = geom;
|
|
22114
22138
|
}
|
|
22115
22139
|
else {
|
|
22116
|
-
var polygon =
|
|
22140
|
+
var polygon = geom.type === 'Feature'
|
|
22141
|
+
? geom.geometry
|
|
22142
|
+
: geom.type === 'Polygon'
|
|
22143
|
+
? geom
|
|
22144
|
+
: false;
|
|
22117
22145
|
if (polygon) {
|
|
22118
|
-
|
|
22146
|
+
geom_ = polygon.coordinates[0];
|
|
22119
22147
|
}
|
|
22120
22148
|
}
|
|
22121
|
-
if (
|
|
22149
|
+
if (geom_) {
|
|
22122
22150
|
// create wkt string
|
|
22123
22151
|
var polygonStr = [];
|
|
22124
|
-
for (var _i = 0, geom_1 =
|
|
22152
|
+
for (var _i = 0, geom_1 = geom_; _i < geom_1.length; _i++) {
|
|
22125
22153
|
var _a = geom_1[_i], lng = _a[0], lat = _a[1];
|
|
22126
22154
|
var _b = degrees2meters(lng, lat), x = _b[0], y = _b[1];
|
|
22127
22155
|
polygonStr.push(x + ' ' + y);
|
|
@@ -22133,18 +22161,22 @@ function featureLayerIdentify(options) {
|
|
|
22133
22161
|
srs: 3857,
|
|
22134
22162
|
layers: layers,
|
|
22135
22163
|
};
|
|
22136
|
-
return options.connector.post('feature_layer.identify', {
|
|
22164
|
+
return options.connector.post('feature_layer.identify', {
|
|
22165
|
+
data: data,
|
|
22166
|
+
signal: signal,
|
|
22167
|
+
cache: cache,
|
|
22168
|
+
});
|
|
22137
22169
|
}
|
|
22138
22170
|
else {
|
|
22139
22171
|
throw new Error('Not valid geometry format to make intersection');
|
|
22140
22172
|
}
|
|
22141
22173
|
}
|
|
22142
22174
|
function sendIdentifyRequest(ev, options) {
|
|
22143
|
-
var _a;
|
|
22144
22175
|
deprecatedMapClick(ev);
|
|
22145
|
-
var
|
|
22146
|
-
var geom =
|
|
22147
|
-
|
|
22176
|
+
var _a = ev.lngLat, lng = _a[0], lat = _a[1];
|
|
22177
|
+
var geom = options.geom, radius = options.radius, signal = options.signal, cache = options.cache;
|
|
22178
|
+
var geom_ = geom !== null && geom !== void 0 ? geom : getCirclePolygonCoordinates(lng, lat, radius);
|
|
22179
|
+
return featureLayerIdentify(__assign(__assign({}, options), { geom: geom_, signal: signal, cache: cache }));
|
|
22148
22180
|
}
|
|
22149
22181
|
function createIdentifyItem(opt) {
|
|
22150
22182
|
return new IdentifyItem(opt);
|
|
@@ -24320,7 +24352,9 @@ var LeafletMapAdapter = /** @class */ (function () {
|
|
|
24320
24352
|
this.options = __assign({}, options);
|
|
24321
24353
|
if (this.options.target) {
|
|
24322
24354
|
var _a = this.options, zoom = _a.zoom, center = _a.center, maxZoom = _a.maxZoom, minZoom = _a.minZoom, mb = _a.maxBounds, mapAdapterOptions = _a.mapAdapterOptions;
|
|
24323
|
-
this.map =
|
|
24355
|
+
this.map =
|
|
24356
|
+
this.options.map ||
|
|
24357
|
+
new leafletSrc.exports.Map(this.options.target, __assign({ attributionControl: false, zoomControl: false, maxBounds: mb ? arrayToBoundsExpression(mb) : undefined, maxZoom: maxZoom, minZoom: minZoom, center: center && [center[1], center[0]], zoom: zoom }, mapAdapterOptions));
|
|
24324
24358
|
// create default pane
|
|
24325
24359
|
var defPane = this.map.createPane('order-0');
|
|
24326
24360
|
this.map._addUnselectCb = function (def) {
|