@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
|
var NgwLeaflet = (function () {
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
@@ -18119,31 +18119,31 @@ var NgwLeaflet = (function () {
|
|
|
18119
18119
|
/**
|
|
18120
18120
|
* Thrown when...
|
|
18121
18121
|
*/
|
|
18122
|
-
var
|
|
18123
|
-
__extends(
|
|
18124
|
-
function
|
|
18122
|
+
var NetworkError = /** @class */ (function (_super) {
|
|
18123
|
+
__extends(NetworkError, _super);
|
|
18124
|
+
function NetworkError(url) {
|
|
18125
18125
|
var _this = _super.call(this) || this;
|
|
18126
|
-
_this.name = '
|
|
18127
|
-
Object.
|
|
18128
|
-
|
|
18126
|
+
_this.name = 'NetworkError';
|
|
18127
|
+
Object.setPrototypeOf(_this, NetworkError.prototype);
|
|
18128
|
+
_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
|
|
18129
18129
|
return _this;
|
|
18130
18130
|
}
|
|
18131
|
-
return
|
|
18131
|
+
return NetworkError;
|
|
18132
18132
|
}(Error));
|
|
18133
18133
|
|
|
18134
18134
|
/**
|
|
18135
18135
|
* Thrown when...
|
|
18136
18136
|
*/
|
|
18137
|
-
var
|
|
18138
|
-
__extends(
|
|
18139
|
-
function
|
|
18137
|
+
var NgwError = /** @class */ (function (_super) {
|
|
18138
|
+
__extends(NgwError, _super);
|
|
18139
|
+
function NgwError(er) {
|
|
18140
18140
|
var _this = _super.call(this) || this;
|
|
18141
|
-
_this.name = '
|
|
18142
|
-
Object.
|
|
18143
|
-
|
|
18141
|
+
_this.name = 'NgwError';
|
|
18142
|
+
Object.assign(_this, er);
|
|
18143
|
+
Object.setPrototypeOf(_this, NgwError.prototype);
|
|
18144
18144
|
return _this;
|
|
18145
18145
|
}
|
|
18146
|
-
return
|
|
18146
|
+
return NgwError;
|
|
18147
18147
|
}(Error));
|
|
18148
18148
|
|
|
18149
18149
|
function isObject(val) {
|
|
@@ -18257,11 +18257,6 @@ var NgwLeaflet = (function () {
|
|
|
18257
18257
|
xhr.abort();
|
|
18258
18258
|
});
|
|
18259
18259
|
}
|
|
18260
|
-
if (options.signal) {
|
|
18261
|
-
options.signal.addEventListener('abort', function () {
|
|
18262
|
-
xhr.abort();
|
|
18263
|
-
});
|
|
18264
|
-
}
|
|
18265
18260
|
xhr.send(data);
|
|
18266
18261
|
};
|
|
18267
18262
|
}
|
|
@@ -18712,6 +18707,7 @@ var NgwLeaflet = (function () {
|
|
|
18712
18707
|
this.id = ID$1++;
|
|
18713
18708
|
this.emitter = new events.exports.EventEmitter();
|
|
18714
18709
|
this.routeStr = '/api/component/pyramid/route';
|
|
18710
|
+
this.activeRequests = [];
|
|
18715
18711
|
var exist = findConnector(options);
|
|
18716
18712
|
if (exist) {
|
|
18717
18713
|
return exist;
|
|
@@ -18797,6 +18793,7 @@ var NgwLeaflet = (function () {
|
|
|
18797
18793
|
* Disconnecting a user. Aborting all current requests
|
|
18798
18794
|
*/
|
|
18799
18795
|
NgwConnector.prototype.logout = function () {
|
|
18796
|
+
this.abort();
|
|
18800
18797
|
removeConnector(this);
|
|
18801
18798
|
this.options.auth = undefined;
|
|
18802
18799
|
this.user = undefined;
|
|
@@ -18849,6 +18846,17 @@ var NgwLeaflet = (function () {
|
|
|
18849
18846
|
}
|
|
18850
18847
|
}
|
|
18851
18848
|
};
|
|
18849
|
+
/** Stop all api requests */
|
|
18850
|
+
NgwConnector.prototype.abort = function () {
|
|
18851
|
+
for (var _i = 0, _a = this.activeRequests; _i < _a.length; _i++) {
|
|
18852
|
+
var req = _a[_i];
|
|
18853
|
+
req.cancel();
|
|
18854
|
+
}
|
|
18855
|
+
this.activeRequests = [];
|
|
18856
|
+
};
|
|
18857
|
+
NgwConnector.prototype.getActiveApiRequests = function () {
|
|
18858
|
+
return __spreadArray([], this.activeRequests, true);
|
|
18859
|
+
};
|
|
18852
18860
|
/**
|
|
18853
18861
|
* Send request to NGW api router.
|
|
18854
18862
|
* @param name - NGW route name from {@link https://docs.nextgis.com/docs_ngweb_dev/doc/developer/resource.html#routes | routes}
|
|
@@ -19063,14 +19071,20 @@ var NgwLeaflet = (function () {
|
|
|
19063
19071
|
NgwConnector.prototype._loadData = function (url, options) {
|
|
19064
19072
|
var _this = this;
|
|
19065
19073
|
options.responseType = options.responseType || 'json';
|
|
19066
|
-
|
|
19074
|
+
var request = new CancelablePromise(function (resolve, reject, onCancel) {
|
|
19067
19075
|
if (_this.user) {
|
|
19068
19076
|
options = options || {};
|
|
19069
19077
|
// options.withCredentials = true;
|
|
19070
19078
|
options.headers = __assign(__assign({}, _this.getAuthorizationHeaders()), options.headers);
|
|
19071
19079
|
}
|
|
19072
19080
|
loadData(url, resolve, options, reject, onCancel);
|
|
19073
|
-
})
|
|
19081
|
+
})
|
|
19082
|
+
.then(function (resp) {
|
|
19083
|
+
_this._cleanActiveRequests(request);
|
|
19084
|
+
return resp;
|
|
19085
|
+
})
|
|
19086
|
+
.catch(function (httpError) {
|
|
19087
|
+
_this._cleanActiveRequests(request);
|
|
19074
19088
|
if (httpError instanceof CancelablePromise.CancelError) ;
|
|
19075
19089
|
else {
|
|
19076
19090
|
// @ts-ignore
|
|
@@ -19083,6 +19097,20 @@ var NgwLeaflet = (function () {
|
|
|
19083
19097
|
}
|
|
19084
19098
|
}
|
|
19085
19099
|
});
|
|
19100
|
+
if (options.signal &&
|
|
19101
|
+
typeof options.signal.addEventListener === 'function') {
|
|
19102
|
+
options.signal.addEventListener('abort', function () {
|
|
19103
|
+
request.cancel();
|
|
19104
|
+
});
|
|
19105
|
+
}
|
|
19106
|
+
this.activeRequests.push(request);
|
|
19107
|
+
return request;
|
|
19108
|
+
};
|
|
19109
|
+
NgwConnector.prototype._cleanActiveRequests = function (request) {
|
|
19110
|
+
var activeRequestIndex = this.activeRequests.indexOf(request);
|
|
19111
|
+
if (activeRequestIndex !== -1) {
|
|
19112
|
+
this.activeRequests.splice(activeRequestIndex, 1);
|
|
19113
|
+
}
|
|
19086
19114
|
};
|
|
19087
19115
|
NgwConnector.prototype._handleHttpError = function (er) {
|
|
19088
19116
|
if (er) {
|
|
@@ -19192,12 +19220,12 @@ var NgwLeaflet = (function () {
|
|
|
19192
19220
|
function fetchNgwExtent(options) {
|
|
19193
19221
|
return options.connector.getResource(options.resourceId).then(function (resource) {
|
|
19194
19222
|
if (resource) {
|
|
19195
|
-
return fetchNgwResourceExtent(resource, options.connector);
|
|
19223
|
+
return fetchNgwResourceExtent(resource, options.connector, options);
|
|
19196
19224
|
}
|
|
19197
19225
|
});
|
|
19198
19226
|
}
|
|
19199
19227
|
/** @deprecated use {@link fetchNgwExtent} instead */
|
|
19200
|
-
function fetchNgwResourceExtent(item, connector) {
|
|
19228
|
+
function fetchNgwResourceExtent(item, connector, options) {
|
|
19201
19229
|
if (item.webmap) {
|
|
19202
19230
|
return CancelablePromise.resolve(getNgwWebmapExtent(item.webmap));
|
|
19203
19231
|
}
|
|
@@ -19206,15 +19234,12 @@ var NgwLeaflet = (function () {
|
|
|
19206
19234
|
if (resource.cls && resource.cls.indexOf('style') !== -1) {
|
|
19207
19235
|
return connector.getResource(resource.parent.id).then(function (res) {
|
|
19208
19236
|
if (res) {
|
|
19209
|
-
return fetchNgwLayerExtent({
|
|
19210
|
-
resourceId: res.resource.id,
|
|
19211
|
-
connector: connector,
|
|
19212
|
-
});
|
|
19237
|
+
return fetchNgwLayerExtent(__assign(__assign({}, options), { resourceId: res.resource.id, connector: connector }));
|
|
19213
19238
|
}
|
|
19214
19239
|
});
|
|
19215
19240
|
}
|
|
19216
19241
|
else {
|
|
19217
|
-
return fetchNgwLayerExtent({ resourceId: resource.id, connector: connector });
|
|
19242
|
+
return fetchNgwLayerExtent(__assign(__assign({}, options), { resourceId: resource.id, connector: connector }));
|
|
19218
19243
|
}
|
|
19219
19244
|
}
|
|
19220
19245
|
}
|
|
@@ -19385,7 +19410,7 @@ var NgwLeaflet = (function () {
|
|
|
19385
19410
|
}
|
|
19386
19411
|
function fetchNgwLayerItemsRequest(options) {
|
|
19387
19412
|
var params = __assign({}, FEATURE_REQUEST_PARAMS);
|
|
19388
|
-
var limit = options.limit, offset = options.offset, orderBy = options.orderBy, paramList = options.paramList, connector = options.connector, intersects = options.intersects, resourceId = options.resourceId;
|
|
19413
|
+
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;
|
|
19389
19414
|
if (limit) {
|
|
19390
19415
|
if (limit !== Number.POSITIVE_INFINITY) {
|
|
19391
19416
|
params.limit = limit;
|
|
@@ -19415,11 +19440,10 @@ var NgwLeaflet = (function () {
|
|
|
19415
19440
|
params.paramList = paramList;
|
|
19416
19441
|
}
|
|
19417
19442
|
var reqParams = __assign({ id: resourceId }, params);
|
|
19418
|
-
return connector.get('feature_layer.feature.collection', { cache:
|
|
19443
|
+
return connector.get('feature_layer.feature.collection', { cache: cache, signal: signal }, reqParams);
|
|
19419
19444
|
}
|
|
19420
19445
|
|
|
19421
19446
|
function prepareNgwFieldsToPropertiesFilter(fields) {
|
|
19422
|
-
console.log(fields);
|
|
19423
19447
|
var f;
|
|
19424
19448
|
var _loop_1 = function () {
|
|
19425
19449
|
var field = fields[f];
|
|
@@ -21428,7 +21452,7 @@ var NgwLeaflet = (function () {
|
|
|
21428
21452
|
});
|
|
21429
21453
|
});
|
|
21430
21454
|
};
|
|
21431
|
-
NgwResource.prototype.getBounds = function () {
|
|
21455
|
+
NgwResource.prototype.getBounds = function (options) {
|
|
21432
21456
|
return __awaiter(this, void 0, void 0, function () {
|
|
21433
21457
|
var _a;
|
|
21434
21458
|
return __generator(this, function (_b) {
|
|
@@ -21439,7 +21463,7 @@ var NgwLeaflet = (function () {
|
|
|
21439
21463
|
}
|
|
21440
21464
|
if (!this.item) return [3 /*break*/, 2];
|
|
21441
21465
|
_a = this;
|
|
21442
|
-
return [4 /*yield*/, fetchNgwResourceExtent(this.item, this.connector)];
|
|
21466
|
+
return [4 /*yield*/, fetchNgwResourceExtent(this.item, this.connector, options)];
|
|
21443
21467
|
case 1:
|
|
21444
21468
|
_a._extent = _b.sent();
|
|
21445
21469
|
return [2 /*return*/, this._extent];
|
|
@@ -22081,7 +22105,7 @@ var NgwLeaflet = (function () {
|
|
|
22081
22105
|
return featureParams;
|
|
22082
22106
|
}
|
|
22083
22107
|
function fetchIdentifyGeoJson(options) {
|
|
22084
|
-
var connector = options.connector, identify = options.identify;
|
|
22108
|
+
var connector = options.connector, identify = options.identify, requestOptions = options.requestOptions;
|
|
22085
22109
|
for (var l in identify) {
|
|
22086
22110
|
var id = Number(l);
|
|
22087
22111
|
if (!isNaN(id)) {
|
|
@@ -22097,7 +22121,7 @@ var NgwLeaflet = (function () {
|
|
|
22097
22121
|
}
|
|
22098
22122
|
var params = getIdentifyItems(identify);
|
|
22099
22123
|
if (params && params.length) {
|
|
22100
|
-
return fetchNgwLayerFeature(__assign({ connector: connector }, params[0]));
|
|
22124
|
+
return fetchNgwLayerFeature(__assign(__assign(__assign({}, requestOptions), { connector: connector }), params[0]));
|
|
22101
22125
|
}
|
|
22102
22126
|
return CancelablePromise.resolve(undefined);
|
|
22103
22127
|
}
|
|
@@ -22110,21 +22134,25 @@ var NgwLeaflet = (function () {
|
|
|
22110
22134
|
return CancelablePromise.resolve(undefined);
|
|
22111
22135
|
}
|
|
22112
22136
|
function featureLayerIdentify(options) {
|
|
22113
|
-
var
|
|
22114
|
-
var
|
|
22115
|
-
if (Array.isArray(
|
|
22116
|
-
|
|
22137
|
+
var geom = options.geom, signal = options.signal, cache = options.cache;
|
|
22138
|
+
var geom_ = [];
|
|
22139
|
+
if (Array.isArray(geom)) {
|
|
22140
|
+
geom_ = geom;
|
|
22117
22141
|
}
|
|
22118
22142
|
else {
|
|
22119
|
-
var polygon =
|
|
22143
|
+
var polygon = geom.type === 'Feature'
|
|
22144
|
+
? geom.geometry
|
|
22145
|
+
: geom.type === 'Polygon'
|
|
22146
|
+
? geom
|
|
22147
|
+
: false;
|
|
22120
22148
|
if (polygon) {
|
|
22121
|
-
|
|
22149
|
+
geom_ = polygon.coordinates[0];
|
|
22122
22150
|
}
|
|
22123
22151
|
}
|
|
22124
|
-
if (
|
|
22152
|
+
if (geom_) {
|
|
22125
22153
|
// create wkt string
|
|
22126
22154
|
var polygonStr = [];
|
|
22127
|
-
for (var _i = 0, geom_1 =
|
|
22155
|
+
for (var _i = 0, geom_1 = geom_; _i < geom_1.length; _i++) {
|
|
22128
22156
|
var _a = geom_1[_i], lng = _a[0], lat = _a[1];
|
|
22129
22157
|
var _b = degrees2meters(lng, lat), x = _b[0], y = _b[1];
|
|
22130
22158
|
polygonStr.push(x + ' ' + y);
|
|
@@ -22136,18 +22164,22 @@ var NgwLeaflet = (function () {
|
|
|
22136
22164
|
srs: 3857,
|
|
22137
22165
|
layers: layers,
|
|
22138
22166
|
};
|
|
22139
|
-
return options.connector.post('feature_layer.identify', {
|
|
22167
|
+
return options.connector.post('feature_layer.identify', {
|
|
22168
|
+
data: data,
|
|
22169
|
+
signal: signal,
|
|
22170
|
+
cache: cache,
|
|
22171
|
+
});
|
|
22140
22172
|
}
|
|
22141
22173
|
else {
|
|
22142
22174
|
throw new Error('Not valid geometry format to make intersection');
|
|
22143
22175
|
}
|
|
22144
22176
|
}
|
|
22145
22177
|
function sendIdentifyRequest(ev, options) {
|
|
22146
|
-
var _a;
|
|
22147
22178
|
deprecatedMapClick(ev);
|
|
22148
|
-
var
|
|
22149
|
-
var geom =
|
|
22150
|
-
|
|
22179
|
+
var _a = ev.lngLat, lng = _a[0], lat = _a[1];
|
|
22180
|
+
var geom = options.geom, radius = options.radius, signal = options.signal, cache = options.cache;
|
|
22181
|
+
var geom_ = geom !== null && geom !== void 0 ? geom : getCirclePolygonCoordinates(lng, lat, radius);
|
|
22182
|
+
return featureLayerIdentify(__assign(__assign({}, options), { geom: geom_, signal: signal, cache: cache }));
|
|
22151
22183
|
}
|
|
22152
22184
|
function createIdentifyItem(opt) {
|
|
22153
22185
|
return new IdentifyItem(opt);
|
|
@@ -24323,7 +24355,9 @@ var NgwLeaflet = (function () {
|
|
|
24323
24355
|
this.options = __assign({}, options);
|
|
24324
24356
|
if (this.options.target) {
|
|
24325
24357
|
var _a = this.options, zoom = _a.zoom, center = _a.center, maxZoom = _a.maxZoom, minZoom = _a.minZoom, mb = _a.maxBounds, mapAdapterOptions = _a.mapAdapterOptions;
|
|
24326
|
-
this.map =
|
|
24358
|
+
this.map =
|
|
24359
|
+
this.options.map ||
|
|
24360
|
+
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));
|
|
24327
24361
|
// create default pane
|
|
24328
24362
|
var defPane = this.map.createPane('order-0');
|
|
24329
24363
|
this.map._addUnselectCb = function (def) {
|