@nextgis/ngw-leaflet 1.5.0 → 1.8.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 +2 -1
- package/lib/ngw-leaflet.esm-browser.js +480 -313
- package/lib/ngw-leaflet.esm-browser.js.map +1 -0
- package/lib/ngw-leaflet.esm-browser.prod.js +3 -2
- package/lib/ngw-leaflet.esm-browser.prod.js.map +1 -0
- package/lib/ngw-leaflet.esm-bundler.js +2 -1
- package/lib/ngw-leaflet.esm-bundler.js.map +1 -0
- package/lib/ngw-leaflet.esm-bundler.prod.js +1 -0
- package/lib/ngw-leaflet.esm-bundler.prod.js.map +1 -0
- package/lib/ngw-leaflet.global.js +589 -446
- package/lib/ngw-leaflet.global.js.map +1 -0
- package/lib/ngw-leaflet.global.prod.js +3 -2
- package/lib/ngw-leaflet.global.prod.js.map +1 -0
- package/package.json +5 -5
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Bundle of @nextgis/ngw-leaflet; version: 1.
|
|
1
|
+
/** Bundle of @nextgis/ngw-leaflet; version: 1.8.0; author: NextGIS */
|
|
2
2
|
function styleInject(css, ref) {
|
|
3
3
|
if ( ref === void 0 ) ref = {};
|
|
4
4
|
var insertAt = ref.insertAt;
|
|
@@ -14721,7 +14721,6 @@ let ID$3 = 0;
|
|
|
14721
14721
|
*
|
|
14722
14722
|
* promise.cancel();
|
|
14723
14723
|
* ```
|
|
14724
|
-
* @public
|
|
14725
14724
|
*/
|
|
14726
14725
|
class CancelablePromise {
|
|
14727
14726
|
constructor(executor, timeout) {
|
|
@@ -15024,8 +15023,7 @@ function debugLog(message) {
|
|
|
15024
15023
|
}
|
|
15025
15024
|
|
|
15026
15025
|
/**
|
|
15027
|
-
*
|
|
15028
|
-
* @param ev @deprecated
|
|
15026
|
+
* @internal
|
|
15029
15027
|
*/
|
|
15030
15028
|
function deprecatedMapClick(ev) {
|
|
15031
15029
|
if (!ev.lngLat && ev.latLng) {
|
|
@@ -15037,6 +15035,7 @@ function deprecatedMapClick(ev) {
|
|
|
15037
15035
|
return ev;
|
|
15038
15036
|
}
|
|
15039
15037
|
|
|
15038
|
+
/** @internal */
|
|
15040
15039
|
function deprecatedWarn(message) {
|
|
15041
15040
|
console.warn(`DEPRECATED WARN: ${message}`);
|
|
15042
15041
|
}
|
|
@@ -15213,8 +15212,8 @@ function objectRemoveEmpty(obj) {
|
|
|
15213
15212
|
return newObj;
|
|
15214
15213
|
}
|
|
15215
15214
|
|
|
15216
|
-
function
|
|
15217
|
-
return
|
|
15215
|
+
function isObject$1(val) {
|
|
15216
|
+
return Object.prototype.toString.call(val) === '[object Object]';
|
|
15218
15217
|
}
|
|
15219
15218
|
|
|
15220
15219
|
function fixUrlStr(url) {
|
|
@@ -15222,13 +15221,6 @@ function fixUrlStr(url) {
|
|
|
15222
15221
|
return url.replace(/([^:]\/)\/+/g, '$1');
|
|
15223
15222
|
}
|
|
15224
15223
|
|
|
15225
|
-
/**
|
|
15226
|
-
* @module utils
|
|
15227
|
-
*/
|
|
15228
|
-
function isObject$1(val) {
|
|
15229
|
-
return Object.prototype.toString.call(val) === '[object Object]';
|
|
15230
|
-
}
|
|
15231
|
-
|
|
15232
15224
|
function isExpression(value) {
|
|
15233
15225
|
if (Array.isArray(value)) {
|
|
15234
15226
|
return true;
|
|
@@ -15317,6 +15309,9 @@ function createExpressionCallback(paint) {
|
|
|
15317
15309
|
return;
|
|
15318
15310
|
}
|
|
15319
15311
|
|
|
15312
|
+
function reEscape(s) {
|
|
15313
|
+
return s.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
15314
|
+
}
|
|
15320
15315
|
function like(b, a, iLike) {
|
|
15321
15316
|
a = String(a);
|
|
15322
15317
|
b = String(b);
|
|
@@ -15376,7 +15371,7 @@ function featureFilter(feature, filters) {
|
|
|
15376
15371
|
function propertiesFilter(properties, filters) {
|
|
15377
15372
|
const logic = typeof filters[0] === 'string' ? filters[0] : 'all';
|
|
15378
15373
|
const filterFunction = (p) => {
|
|
15379
|
-
if (
|
|
15374
|
+
if (isPropertyFilter(p)) {
|
|
15380
15375
|
const [field, operation, value] = p;
|
|
15381
15376
|
const operationExec = operationsAliases[operation];
|
|
15382
15377
|
if (operationExec) {
|
|
@@ -15767,7 +15762,7 @@ function clearObject(obj) {
|
|
|
15767
15762
|
let ID$2 = 0;
|
|
15768
15763
|
const OPTIONS$1 = {
|
|
15769
15764
|
minZoom: 0,
|
|
15770
|
-
maxZoom:
|
|
15765
|
+
maxZoom: 20,
|
|
15771
15766
|
paint: {
|
|
15772
15767
|
color: 'blue',
|
|
15773
15768
|
opacity: 0.4,
|
|
@@ -15925,7 +15920,7 @@ class WebMapMain {
|
|
|
15925
15920
|
}
|
|
15926
15921
|
/**
|
|
15927
15922
|
* Returns the map's geographical centerpoint.
|
|
15928
|
-
* @
|
|
15923
|
+
* @returns lngLat Array of two numbers representing longitude and latitude of the center of the map view.
|
|
15929
15924
|
*
|
|
15930
15925
|
* @example
|
|
15931
15926
|
* ```javascript
|
|
@@ -15958,7 +15953,7 @@ class WebMapMain {
|
|
|
15958
15953
|
}
|
|
15959
15954
|
/**
|
|
15960
15955
|
* Returns the map's current zoom level.
|
|
15961
|
-
* @
|
|
15956
|
+
* @returns The map's current zoom level (0-24).
|
|
15962
15957
|
*/
|
|
15963
15958
|
getZoom() {
|
|
15964
15959
|
return this.mapAdapter.getZoom();
|
|
@@ -16293,8 +16288,10 @@ class WebMapLayers extends WebMapMain {
|
|
|
16293
16288
|
*/
|
|
16294
16289
|
async fitLayer(layerDef, options) {
|
|
16295
16290
|
const layer = this.getLayer(layerDef);
|
|
16296
|
-
|
|
16297
|
-
|
|
16291
|
+
// TODO: remove backward compatibility for `getExtent`
|
|
16292
|
+
const getBounds = layer && (layer.getBounds || layer.getExtent);
|
|
16293
|
+
if (getBounds) {
|
|
16294
|
+
const extent = await getBounds.call(layer);
|
|
16298
16295
|
if (extent) {
|
|
16299
16296
|
this.fitBounds(extent, options);
|
|
16300
16297
|
}
|
|
@@ -16382,7 +16379,7 @@ class WebMapLayers extends WebMapMain {
|
|
|
16382
16379
|
const layer = await this.addLayer(adapter, {
|
|
16383
16380
|
...options,
|
|
16384
16381
|
baselayer: true,
|
|
16385
|
-
});
|
|
16382
|
+
}, undefined);
|
|
16386
16383
|
return layer;
|
|
16387
16384
|
}
|
|
16388
16385
|
/**
|
|
@@ -16402,7 +16399,7 @@ class WebMapLayers extends WebMapMain {
|
|
|
16402
16399
|
async addLayer(adapter, options = {}, order) {
|
|
16403
16400
|
var _a, _b;
|
|
16404
16401
|
const id = this._layersIdCounter++;
|
|
16405
|
-
const _order = order
|
|
16402
|
+
const _order = defined(order)
|
|
16406
16403
|
? order
|
|
16407
16404
|
: options.order !== undefined
|
|
16408
16405
|
? options.order
|
|
@@ -16497,8 +16494,10 @@ class WebMapLayers extends WebMapMain {
|
|
|
16497
16494
|
if (opacity !== undefined && opacity <= 1) {
|
|
16498
16495
|
this.setLayerOpacity(_adapter, opacity);
|
|
16499
16496
|
}
|
|
16500
|
-
|
|
16501
|
-
|
|
16497
|
+
// TODO: remove backward compatibility for `getExtent`
|
|
16498
|
+
const getBounds = layer && (_adapter.getBounds || _adapter.getExtent);
|
|
16499
|
+
if (options.fit && getBounds) {
|
|
16500
|
+
const extent = await getBounds.call(_adapter);
|
|
16502
16501
|
if (extent) {
|
|
16503
16502
|
await this.fitBounds(extent);
|
|
16504
16503
|
}
|
|
@@ -16621,10 +16620,18 @@ class WebMapLayers extends WebMapMain {
|
|
|
16621
16620
|
opt.paint = opt.paint || {};
|
|
16622
16621
|
return this.addLayer(adapter || 'GEOJSON', opt);
|
|
16623
16622
|
}
|
|
16624
|
-
/** Shortcut for {@link WebMapLayers.addGeoJsonLayer} to
|
|
16623
|
+
/** Shortcut for {@link WebMapLayers.addGeoJsonLayer} to create GeoJson adapter with generic types for working in typescript */
|
|
16625
16624
|
addFeatureLayer(options = {}) {
|
|
16626
16625
|
return this.addGeoJsonLayer(options);
|
|
16627
16626
|
}
|
|
16627
|
+
/** Shortcut for {@link WebMapLayers.addLayer} to create TileLayer adapter */
|
|
16628
|
+
addTileLayer(url, options) {
|
|
16629
|
+
return this.addLayer('TILE', { ...options, url });
|
|
16630
|
+
}
|
|
16631
|
+
/** Shortcut for {@link WebMapLayers.addLayer} to create TileLayer adapter */
|
|
16632
|
+
addImageLayer(url, options) {
|
|
16633
|
+
return this.addLayer('IMAGE', { ...options, url });
|
|
16634
|
+
}
|
|
16628
16635
|
/**
|
|
16629
16636
|
* Show added layer on the map by it definition.
|
|
16630
16637
|
*/
|
|
@@ -16655,7 +16662,7 @@ class WebMapLayers extends WebMapMain {
|
|
|
16655
16662
|
const onMap = layer && layer.options.visibility;
|
|
16656
16663
|
const toStatus = status !== undefined ? status : !onMap;
|
|
16657
16664
|
const silent = options.silent !== undefined ? options.silent : false;
|
|
16658
|
-
const action = (l) => {
|
|
16665
|
+
const action = async (l) => {
|
|
16659
16666
|
const id = String(l.id);
|
|
16660
16667
|
const preEventName = toStatus ? 'layer:preshow' : 'layer:prehide';
|
|
16661
16668
|
const eventName = toStatus ? 'layer:show' : 'layer:hide';
|
|
@@ -16667,11 +16674,11 @@ class WebMapLayers extends WebMapMain {
|
|
|
16667
16674
|
const order = l.options.baselayer ? 0 : l.options.order;
|
|
16668
16675
|
// do not show baselayer if another on the map
|
|
16669
16676
|
if (l.options.baselayer && this._baselayers.length) {
|
|
16670
|
-
const
|
|
16677
|
+
const anotherVisibleBaselayers = this._baselayers.filter((x) => {
|
|
16671
16678
|
return x !== l.id && this.isLayerVisible(x);
|
|
16672
16679
|
});
|
|
16673
|
-
|
|
16674
|
-
this.hideLayer(
|
|
16680
|
+
for (const bl of anotherVisibleBaselayers) {
|
|
16681
|
+
await this.hideLayer(bl);
|
|
16675
16682
|
}
|
|
16676
16683
|
}
|
|
16677
16684
|
if (l.showLayer) {
|
|
@@ -17109,7 +17116,6 @@ function createToggleControl(createButtonControl, options) {
|
|
|
17109
17116
|
|
|
17110
17117
|
/**
|
|
17111
17118
|
* Collection of methods for managing map controls
|
|
17112
|
-
* @public
|
|
17113
17119
|
*/
|
|
17114
17120
|
class WebMapControls extends WebMapLayers {
|
|
17115
17121
|
constructor() {
|
|
@@ -17189,7 +17195,6 @@ class WebMapControls extends WebMapLayers {
|
|
|
17189
17195
|
* webMap.addControl(toggleControl, 'top-right');
|
|
17190
17196
|
* ```
|
|
17191
17197
|
* {@link http://code.nextgis.com/demo-examples-toggle-control | Toggle button control example}
|
|
17192
|
-
* @public
|
|
17193
17198
|
*/
|
|
17194
17199
|
async createToggleControl(options) {
|
|
17195
17200
|
await this.onLoad('build-map');
|
|
@@ -17206,7 +17211,6 @@ class WebMapControls extends WebMapLayers {
|
|
|
17206
17211
|
*
|
|
17207
17212
|
* @param control - Instance of WEB-GIS framework control.
|
|
17208
17213
|
* What is returned by the {@Link WebMapControls.createControl | create} method
|
|
17209
|
-
* @public
|
|
17210
17214
|
*/
|
|
17211
17215
|
removeControl(control) {
|
|
17212
17216
|
if ('remove' in control) {
|
|
@@ -17223,7 +17227,6 @@ class WebMapControls extends WebMapLayers {
|
|
|
17223
17227
|
* Get instance of registered control
|
|
17224
17228
|
* @param control - Any registered control string name
|
|
17225
17229
|
* @param options - Custom control options
|
|
17226
|
-
* @public
|
|
17227
17230
|
*/
|
|
17228
17231
|
getControl(control, options) {
|
|
17229
17232
|
const engine = this.mapAdapter.controlAdapters[control];
|
|
@@ -17351,7 +17354,6 @@ function setWebMap(id, webMap) {
|
|
|
17351
17354
|
* @typeParam C - Control
|
|
17352
17355
|
* @typeParam E - Events
|
|
17353
17356
|
*
|
|
17354
|
-
* @public
|
|
17355
17357
|
*/
|
|
17356
17358
|
class WebMap extends WebMapControls {
|
|
17357
17359
|
constructor(mapOptions) {
|
|
@@ -17366,24 +17368,19 @@ class WebMap extends WebMapControls {
|
|
|
17366
17368
|
* @internal
|
|
17367
17369
|
*/
|
|
17368
17370
|
async _addLayerProviders() {
|
|
17369
|
-
|
|
17370
|
-
|
|
17371
|
-
|
|
17372
|
-
|
|
17373
|
-
|
|
17374
|
-
|
|
17375
|
-
|
|
17376
|
-
|
|
17377
|
-
this.mapAdapter.layerAdapters[adapter.name] = newAdapter;
|
|
17378
|
-
}
|
|
17371
|
+
for await (const kit of this._starterKits) {
|
|
17372
|
+
if (kit.getLayerAdapters) {
|
|
17373
|
+
const adapters = await kit.getLayerAdapters.call(kit);
|
|
17374
|
+
if (adapters) {
|
|
17375
|
+
for await (const adapter of adapters) {
|
|
17376
|
+
const newAdapter = await adapter.createAdapter(this);
|
|
17377
|
+
if (newAdapter) {
|
|
17378
|
+
this.mapAdapter.layerAdapters[adapter.name] = newAdapter;
|
|
17379
17379
|
}
|
|
17380
17380
|
}
|
|
17381
17381
|
}
|
|
17382
17382
|
}
|
|
17383
17383
|
}
|
|
17384
|
-
catch (er) {
|
|
17385
|
-
throw new Error(er);
|
|
17386
|
-
}
|
|
17387
17384
|
}
|
|
17388
17385
|
/**
|
|
17389
17386
|
* @internal
|
|
@@ -18415,6 +18412,66 @@ function getLayerFilterOptions(options) {
|
|
|
18415
18412
|
return filterOptions;
|
|
18416
18413
|
}
|
|
18417
18414
|
|
|
18415
|
+
function getNgwWebmapExtent(webmap) {
|
|
18416
|
+
const bottom = webmap['extent_bottom'];
|
|
18417
|
+
const left = webmap['extent_left'];
|
|
18418
|
+
const top = webmap['extent_top'];
|
|
18419
|
+
const right = webmap['extent_right'];
|
|
18420
|
+
if (bottom && left && top && right) {
|
|
18421
|
+
const extent = [left, bottom, right, top];
|
|
18422
|
+
if (extent[3] > 82) {
|
|
18423
|
+
extent[3] = 82;
|
|
18424
|
+
}
|
|
18425
|
+
if (extent[1] < -82) {
|
|
18426
|
+
extent[1] = -82;
|
|
18427
|
+
}
|
|
18428
|
+
return extent;
|
|
18429
|
+
}
|
|
18430
|
+
}
|
|
18431
|
+
function fetchNgwLayerExtent({ resourceId, connector, cache = true, }) {
|
|
18432
|
+
return connector
|
|
18433
|
+
.get('layer.extent', { cache }, { id: resourceId })
|
|
18434
|
+
.then((resp) => {
|
|
18435
|
+
if (resp) {
|
|
18436
|
+
const { maxLat, maxLon, minLat, minLon } = resp.extent;
|
|
18437
|
+
const extentArray = [minLon, minLat, maxLon, maxLat];
|
|
18438
|
+
return extentArray;
|
|
18439
|
+
}
|
|
18440
|
+
});
|
|
18441
|
+
}
|
|
18442
|
+
function fetchNgwLayerItemExtent({ resourceId, featureId, connector, cache = true, }) {
|
|
18443
|
+
return connector
|
|
18444
|
+
.get('feature_layer.feature.item_extent', { cache }, { id: resourceId, fid: featureId })
|
|
18445
|
+
.then((resp) => {
|
|
18446
|
+
if (resp) {
|
|
18447
|
+
const { maxLat, maxLon, minLat, minLon } = resp.extent;
|
|
18448
|
+
const extentArray = [minLon, minLat, maxLon, maxLat];
|
|
18449
|
+
return extentArray;
|
|
18450
|
+
}
|
|
18451
|
+
});
|
|
18452
|
+
}
|
|
18453
|
+
function fetchNgwResourceExtent(item, connector) {
|
|
18454
|
+
if (item.webmap) {
|
|
18455
|
+
return CancelablePromise.resolve(getNgwWebmapExtent(item.webmap));
|
|
18456
|
+
}
|
|
18457
|
+
else {
|
|
18458
|
+
const resource = item.resource;
|
|
18459
|
+
if (resource.cls && resource.cls.indexOf('style') !== -1) {
|
|
18460
|
+
return connector.getResource(resource.parent.id).then((res) => {
|
|
18461
|
+
if (res) {
|
|
18462
|
+
return fetchNgwLayerExtent({
|
|
18463
|
+
resourceId: res.resource.id,
|
|
18464
|
+
connector,
|
|
18465
|
+
});
|
|
18466
|
+
}
|
|
18467
|
+
});
|
|
18468
|
+
}
|
|
18469
|
+
else {
|
|
18470
|
+
return fetchNgwLayerExtent({ resourceId: resource.id, connector });
|
|
18471
|
+
}
|
|
18472
|
+
}
|
|
18473
|
+
}
|
|
18474
|
+
|
|
18418
18475
|
async function resourceIdFromLayerOptions(options, connector) {
|
|
18419
18476
|
const resource = options.resource;
|
|
18420
18477
|
const item = resource;
|
|
@@ -18653,55 +18710,6 @@ function fetchNgwLayerFeatureCollection(options) {
|
|
|
18653
18710
|
});
|
|
18654
18711
|
}
|
|
18655
18712
|
|
|
18656
|
-
function getNgwWebmapExtent(webmap) {
|
|
18657
|
-
const bottom = webmap['extent_bottom'];
|
|
18658
|
-
const left = webmap['extent_left'];
|
|
18659
|
-
const top = webmap['extent_top'];
|
|
18660
|
-
const right = webmap['extent_right'];
|
|
18661
|
-
if (bottom && left && top && right) {
|
|
18662
|
-
const extent = [left, bottom, right, top];
|
|
18663
|
-
if (extent[3] > 82) {
|
|
18664
|
-
extent[3] = 82;
|
|
18665
|
-
}
|
|
18666
|
-
if (extent[1] < -82) {
|
|
18667
|
-
extent[1] = -82;
|
|
18668
|
-
}
|
|
18669
|
-
return extent;
|
|
18670
|
-
}
|
|
18671
|
-
}
|
|
18672
|
-
function fetchNgwLayerExtent({ resourceId, connector, cache = true, }) {
|
|
18673
|
-
return connector
|
|
18674
|
-
.get('layer.extent', { cache }, { id: resourceId })
|
|
18675
|
-
.then((resp) => {
|
|
18676
|
-
if (resp) {
|
|
18677
|
-
const { maxLat, maxLon, minLat, minLon } = resp.extent;
|
|
18678
|
-
const extentArray = [minLon, minLat, maxLon, maxLat];
|
|
18679
|
-
return extentArray;
|
|
18680
|
-
}
|
|
18681
|
-
});
|
|
18682
|
-
}
|
|
18683
|
-
function fetchNgwResourceExtent(item, connector) {
|
|
18684
|
-
if (item.webmap) {
|
|
18685
|
-
return CancelablePromise.resolve(getNgwWebmapExtent(item.webmap));
|
|
18686
|
-
}
|
|
18687
|
-
else {
|
|
18688
|
-
const resource = item.resource;
|
|
18689
|
-
if (resource.cls && resource.cls.indexOf('style') !== -1) {
|
|
18690
|
-
return connector.getResource(resource.parent.id).then((res) => {
|
|
18691
|
-
if (res) {
|
|
18692
|
-
return fetchNgwLayerExtent({
|
|
18693
|
-
resourceId: res.resource.id,
|
|
18694
|
-
connector,
|
|
18695
|
-
});
|
|
18696
|
-
}
|
|
18697
|
-
});
|
|
18698
|
-
}
|
|
18699
|
-
else {
|
|
18700
|
-
return fetchNgwLayerExtent({ resourceId: resource.id, connector });
|
|
18701
|
-
}
|
|
18702
|
-
}
|
|
18703
|
-
}
|
|
18704
|
-
|
|
18705
18713
|
async function createGeoJsonAdapter(props) {
|
|
18706
18714
|
var _a, _b;
|
|
18707
18715
|
const { item, webMap, Adapter, connector, layerOptions, addLayerOptionsPriority: alop, } = props;
|
|
@@ -18790,14 +18798,18 @@ async function createGeoJsonAdapter(props) {
|
|
|
18790
18798
|
}
|
|
18791
18799
|
return layer;
|
|
18792
18800
|
}
|
|
18801
|
+
/** @deprecated use {@link NgwGeoJsonAdapter.getBounds} instead */
|
|
18793
18802
|
getExtent() {
|
|
18803
|
+
return this.getBounds();
|
|
18804
|
+
}
|
|
18805
|
+
async getBounds() {
|
|
18794
18806
|
const hasData = this.getLayers && this.getLayers().length;
|
|
18795
18807
|
if (this.options.strategy === 'BBOX' || hasData) {
|
|
18796
18808
|
return fetchNgwResourceExtent(item, connector);
|
|
18797
18809
|
}
|
|
18798
18810
|
else {
|
|
18799
|
-
if (super.
|
|
18800
|
-
return super.
|
|
18811
|
+
if (super.getBounds) {
|
|
18812
|
+
return super.getBounds();
|
|
18801
18813
|
}
|
|
18802
18814
|
}
|
|
18803
18815
|
}
|
|
@@ -18847,7 +18859,7 @@ async function createGeoJsonAdapter(props) {
|
|
|
18847
18859
|
this.emitter.emit('updated');
|
|
18848
18860
|
}
|
|
18849
18861
|
catch (er) {
|
|
18850
|
-
if (er.name !== 'CancelError') {
|
|
18862
|
+
if (er instanceof Error && er.name !== 'CancelError') {
|
|
18851
18863
|
throw er;
|
|
18852
18864
|
}
|
|
18853
18865
|
}
|
|
@@ -18931,10 +18943,10 @@ async function createGeoJsonAdapter(props) {
|
|
|
18931
18943
|
return NgwGeoJsonAdapter;
|
|
18932
18944
|
}
|
|
18933
18945
|
|
|
18934
|
-
function
|
|
18946
|
+
function ngwApiToAdapterOptions({ options, webMap, baseUrl, }) {
|
|
18935
18947
|
let adapter = options.adapter || 'IMAGE';
|
|
18936
18948
|
let url;
|
|
18937
|
-
const layerAdapters = webMap.getLayerAdapters();
|
|
18949
|
+
const layerAdapters = webMap && webMap.getLayerAdapters();
|
|
18938
18950
|
const isImageAllowed = layerAdapters ? layerAdapters.IMAGE : true;
|
|
18939
18951
|
const resourceId = options.resource;
|
|
18940
18952
|
const nd = options.tileNoData ? options.tileNoData : 200;
|
|
@@ -19024,10 +19036,10 @@ async function createRasterAdapter({ layerOptions, webMap, connector, item, }) {
|
|
|
19024
19036
|
adapter = 'TILE';
|
|
19025
19037
|
}
|
|
19026
19038
|
}
|
|
19027
|
-
const
|
|
19028
|
-
if (
|
|
19039
|
+
const AdapterClass = webMap.mapAdapter.layerAdapters[adapter];
|
|
19040
|
+
if (AdapterClass) {
|
|
19029
19041
|
const resourceId = await resourceIdFromLayerOptions(layerOptions, connector);
|
|
19030
|
-
return class
|
|
19042
|
+
return class RasterAdapter extends AdapterClass {
|
|
19031
19043
|
constructor(map, _options) {
|
|
19032
19044
|
var _a;
|
|
19033
19045
|
super(map, _options);
|
|
@@ -19035,7 +19047,11 @@ async function createRasterAdapter({ layerOptions, webMap, connector, item, }) {
|
|
|
19035
19047
|
// options = {};
|
|
19036
19048
|
this.item = item;
|
|
19037
19049
|
this.resourceId = resourceId;
|
|
19038
|
-
const opt =
|
|
19050
|
+
const opt = ngwApiToAdapterOptions({
|
|
19051
|
+
options: layerOptions,
|
|
19052
|
+
webMap,
|
|
19053
|
+
baseUrl: connector.options.baseUrl || '',
|
|
19054
|
+
});
|
|
19039
19055
|
if (opt) {
|
|
19040
19056
|
const layerAdapterOptions = {
|
|
19041
19057
|
...opt,
|
|
@@ -19750,12 +19766,13 @@ NgwWebmapItem.options = {
|
|
|
19750
19766
|
],
|
|
19751
19767
|
};
|
|
19752
19768
|
|
|
19753
|
-
async function
|
|
19769
|
+
async function createOnFirstShowAdapter({ webMap, adapterOptions = {}, onLayerAdded, createAdapter, }) {
|
|
19754
19770
|
class OnFirstShowAdapter {
|
|
19755
19771
|
constructor() {
|
|
19756
19772
|
this.options = {};
|
|
19757
19773
|
this.layer = [];
|
|
19758
19774
|
this._removed = false;
|
|
19775
|
+
this._creatingInProgress = false;
|
|
19759
19776
|
}
|
|
19760
19777
|
addLayer() {
|
|
19761
19778
|
return this.layer;
|
|
@@ -19764,6 +19781,9 @@ async function createOnFirstShowNgwAdapter({ webMap, connector, item, adapterOpt
|
|
|
19764
19781
|
this._removed = true;
|
|
19765
19782
|
this.layer.forEach((x) => webMap.removeLayer(x));
|
|
19766
19783
|
}
|
|
19784
|
+
destroyed() {
|
|
19785
|
+
return this._removed;
|
|
19786
|
+
}
|
|
19767
19787
|
showLayer() {
|
|
19768
19788
|
this.options.visibility = true;
|
|
19769
19789
|
if (this.layer.length) {
|
|
@@ -19772,34 +19792,38 @@ async function createOnFirstShowNgwAdapter({ webMap, connector, item, adapterOpt
|
|
|
19772
19792
|
});
|
|
19773
19793
|
}
|
|
19774
19794
|
else {
|
|
19775
|
-
|
|
19776
|
-
|
|
19777
|
-
|
|
19778
|
-
|
|
19779
|
-
|
|
19780
|
-
|
|
19781
|
-
|
|
19782
|
-
|
|
19783
|
-
|
|
19784
|
-
|
|
19785
|
-
|
|
19786
|
-
|
|
19787
|
-
|
|
19788
|
-
|
|
19789
|
-
|
|
19790
|
-
|
|
19791
|
-
|
|
19792
|
-
|
|
19793
|
-
webMap.removeLayer(adapter);
|
|
19794
|
-
}
|
|
19795
|
-
if (this.options.visibility) {
|
|
19796
|
-
webMap.showLayer(adapter);
|
|
19797
|
-
}
|
|
19798
|
-
this.layer.push(adapter);
|
|
19799
|
-
});
|
|
19795
|
+
this.loadLayer();
|
|
19796
|
+
}
|
|
19797
|
+
}
|
|
19798
|
+
async loadLayer() {
|
|
19799
|
+
if (!this.layer.length && !this._creatingInProgress) {
|
|
19800
|
+
this._creatingInProgress = true;
|
|
19801
|
+
const Adapter = await createAdapter(this);
|
|
19802
|
+
if (Adapter) {
|
|
19803
|
+
const adapter = new Adapter(webMap.mapAdapter.map, {
|
|
19804
|
+
...adapterOptions,
|
|
19805
|
+
});
|
|
19806
|
+
const realLayer = await adapter.addLayer({
|
|
19807
|
+
order: this.options.order,
|
|
19808
|
+
headers: this.options.headers,
|
|
19809
|
+
baselayer: this.options.baselayer,
|
|
19810
|
+
});
|
|
19811
|
+
if (onLayerAdded) {
|
|
19812
|
+
onLayerAdded(adapter);
|
|
19800
19813
|
}
|
|
19801
|
-
|
|
19814
|
+
Object.assign(adapter.options, adapterOptions);
|
|
19815
|
+
adapter.layer = realLayer;
|
|
19816
|
+
if (this._removed) {
|
|
19817
|
+
webMap.removeLayer(adapter);
|
|
19818
|
+
}
|
|
19819
|
+
if (this.options.visibility) {
|
|
19820
|
+
await webMap.showLayer(adapter);
|
|
19821
|
+
}
|
|
19822
|
+
this.layer.push(adapter);
|
|
19823
|
+
this._creatingInProgress = false;
|
|
19824
|
+
}
|
|
19802
19825
|
}
|
|
19826
|
+
return this.layer;
|
|
19803
19827
|
}
|
|
19804
19828
|
hideLayer() {
|
|
19805
19829
|
this.options.visibility = false;
|
|
@@ -19811,6 +19835,29 @@ async function createOnFirstShowNgwAdapter({ webMap, connector, item, adapterOpt
|
|
|
19811
19835
|
return OnFirstShowAdapter;
|
|
19812
19836
|
}
|
|
19813
19837
|
|
|
19838
|
+
async function createOnFirstShowNgwAdapter({ webMap, connector, item, adapterOptions = {}, idPrefix = 'first-show-adapter', }) {
|
|
19839
|
+
const createAdapter = () => {
|
|
19840
|
+
return createAsyncAdapter({
|
|
19841
|
+
resource: item.resource_id,
|
|
19842
|
+
adapterOptions: {
|
|
19843
|
+
name: item.display_name,
|
|
19844
|
+
opacity: item.opacity,
|
|
19845
|
+
},
|
|
19846
|
+
}, webMap, connector);
|
|
19847
|
+
};
|
|
19848
|
+
const onLayerAdded = (adapter) => {
|
|
19849
|
+
adapter.options.baselayer = false;
|
|
19850
|
+
adapter.id = idPrefix + '-' + item.resource_id;
|
|
19851
|
+
};
|
|
19852
|
+
const OnFirstNgwShowAdapter = createOnFirstShowAdapter({
|
|
19853
|
+
webMap,
|
|
19854
|
+
adapterOptions,
|
|
19855
|
+
onLayerAdded,
|
|
19856
|
+
createAdapter,
|
|
19857
|
+
});
|
|
19858
|
+
return OnFirstNgwShowAdapter;
|
|
19859
|
+
}
|
|
19860
|
+
|
|
19814
19861
|
class BookmarkItem {
|
|
19815
19862
|
constructor(options) {
|
|
19816
19863
|
this.options = options;
|
|
@@ -19912,7 +19959,11 @@ class NgwWebmapLayerAdapter {
|
|
|
19912
19959
|
this.layer.properties.property('visibility').set(false);
|
|
19913
19960
|
}
|
|
19914
19961
|
}
|
|
19962
|
+
/** @deprecated use {@link NgwWebmapLayerAdapter.getBounds} instead */
|
|
19915
19963
|
getExtent() {
|
|
19964
|
+
return this.getBounds();
|
|
19965
|
+
}
|
|
19966
|
+
getBounds() {
|
|
19916
19967
|
const webmap = this.response && this.response.webmap;
|
|
19917
19968
|
if (webmap) {
|
|
19918
19969
|
return getNgwWebmapExtent(webmap);
|
|
@@ -20044,6 +20095,7 @@ class NgwWebmapLayerAdapter {
|
|
|
20044
20095
|
// to avoid set many basemaps on init
|
|
20045
20096
|
const visibility = enabledAlreadySet ? false : x.enabled;
|
|
20046
20097
|
webMap.addBaseLayer(adapter, {
|
|
20098
|
+
id: WEBMAP_BASELAYER_ID_PREFIX + x.resource_id,
|
|
20047
20099
|
name: x.display_name,
|
|
20048
20100
|
opacity: x.opacity,
|
|
20049
20101
|
visibility,
|
|
@@ -20072,10 +20124,14 @@ class NgwWebmapLayerAdapter {
|
|
|
20072
20124
|
item.resourceId = resourceId;
|
|
20073
20125
|
item.updateWmsParams = (params) => updateImageParams(params, resourceId);
|
|
20074
20126
|
const adapter = item.layer_adapter.toUpperCase();
|
|
20075
|
-
const layerAdapterOptions =
|
|
20076
|
-
|
|
20077
|
-
|
|
20078
|
-
|
|
20127
|
+
const layerAdapterOptions = ngwApiToAdapterOptions({
|
|
20128
|
+
options: {
|
|
20129
|
+
adapter,
|
|
20130
|
+
resource: resourceId,
|
|
20131
|
+
},
|
|
20132
|
+
webMap,
|
|
20133
|
+
baseUrl: this.options.connector.options.baseUrl || '',
|
|
20134
|
+
});
|
|
20079
20135
|
item = {
|
|
20080
20136
|
...item,
|
|
20081
20137
|
...layerAdapterOptions,
|
|
@@ -20125,12 +20181,16 @@ async function createWebMapAdapter({ layerOptions: options, webMap, connector, }
|
|
|
20125
20181
|
}
|
|
20126
20182
|
|
|
20127
20183
|
class NgwResource {
|
|
20184
|
+
/** @deprecated use {@link NgwResource.getBounds} instead */
|
|
20128
20185
|
async getExtent() {
|
|
20186
|
+
return this.getBounds();
|
|
20187
|
+
}
|
|
20188
|
+
async getBounds() {
|
|
20129
20189
|
if (this._extent) {
|
|
20130
20190
|
return this._extent;
|
|
20131
20191
|
}
|
|
20132
20192
|
if (this.item) {
|
|
20133
|
-
this._extent = await fetchNgwResourceExtent(this.item, this.connector)
|
|
20193
|
+
this._extent = await fetchNgwResourceExtent(this.item, this.connector);
|
|
20134
20194
|
return this._extent;
|
|
20135
20195
|
}
|
|
20136
20196
|
}
|
|
@@ -20450,7 +20510,7 @@ const vectorLayerGeomToPaintTypeAlias = {
|
|
|
20450
20510
|
MULTILINESTRINGZ: 'line',
|
|
20451
20511
|
MULTIPOLYGONZ: 'polygon',
|
|
20452
20512
|
};
|
|
20453
|
-
function
|
|
20513
|
+
function createNgwLayerAdapter(options, webMap, connector) {
|
|
20454
20514
|
const headers = connector.getAuthorizationHeaders();
|
|
20455
20515
|
if (headers) {
|
|
20456
20516
|
options.headers = headers;
|
|
@@ -20566,14 +20626,14 @@ class IdentifyItem {
|
|
|
20566
20626
|
constructor(options) {
|
|
20567
20627
|
const f = options.feature;
|
|
20568
20628
|
this.id = f.id;
|
|
20629
|
+
this.geom = f.geom;
|
|
20569
20630
|
this.label = f.label;
|
|
20570
|
-
this.layerId = f.layerId;
|
|
20571
20631
|
this.parent = f.parent;
|
|
20572
20632
|
this.fields = f.fields;
|
|
20573
|
-
this.
|
|
20633
|
+
this.layerId = f.layerId;
|
|
20574
20634
|
this.connector = options.connector;
|
|
20575
20635
|
}
|
|
20576
|
-
identify() {
|
|
20636
|
+
identify(options = {}) {
|
|
20577
20637
|
if (this._item) {
|
|
20578
20638
|
return CancelablePromise.resolve(this._item);
|
|
20579
20639
|
}
|
|
@@ -20583,6 +20643,7 @@ class IdentifyItem {
|
|
|
20583
20643
|
resourceId: this.layerId,
|
|
20584
20644
|
fields: null,
|
|
20585
20645
|
extensions: ['attachment', 'description'],
|
|
20646
|
+
...options,
|
|
20586
20647
|
}).then((resp) => {
|
|
20587
20648
|
this._item = resp;
|
|
20588
20649
|
this.geom = resp.geom;
|
|
@@ -20599,6 +20660,16 @@ class IdentifyItem {
|
|
|
20599
20660
|
return this._resource.feature_layer;
|
|
20600
20661
|
});
|
|
20601
20662
|
}
|
|
20663
|
+
getBounds() {
|
|
20664
|
+
if (this._extent) {
|
|
20665
|
+
return CancelablePromise.resolve(this._extent);
|
|
20666
|
+
}
|
|
20667
|
+
return fetchNgwLayerItemExtent({
|
|
20668
|
+
connector: this.connector,
|
|
20669
|
+
featureId: this.id,
|
|
20670
|
+
resourceId: this.layerId,
|
|
20671
|
+
});
|
|
20672
|
+
}
|
|
20602
20673
|
geojson() {
|
|
20603
20674
|
if (this._geojson) {
|
|
20604
20675
|
return CancelablePromise.resolve(this._geojson);
|
|
@@ -20612,6 +20683,8 @@ class IdentifyItem {
|
|
|
20612
20683
|
}
|
|
20613
20684
|
}
|
|
20614
20685
|
|
|
20686
|
+
const WEBMAP_BASELAYER_ID_PREFIX = 'webmap-baselayer';
|
|
20687
|
+
|
|
20615
20688
|
function fetchNgwLayerItem(options) {
|
|
20616
20689
|
const params = {
|
|
20617
20690
|
...FEATURE_REQUEST_PARAMS,
|
|
@@ -20940,6 +21013,14 @@ function prepareWebMapOptions(options) {
|
|
|
20940
21013
|
return options;
|
|
20941
21014
|
}
|
|
20942
21015
|
|
|
21016
|
+
function getIdentifyRadius(center, zoom, pixelRadius) {
|
|
21017
|
+
pixelRadius = pixelRadius !== null && pixelRadius !== void 0 ? pixelRadius : 10;
|
|
21018
|
+
const metresPerPixel = (40075016.686 * Math.abs(Math.cos((center[1] * 180) / Math.PI))) /
|
|
21019
|
+
Math.pow(2, zoom + 8);
|
|
21020
|
+
const radius = pixelRadius * metresPerPixel * 0.0005;
|
|
21021
|
+
return radius;
|
|
21022
|
+
}
|
|
21023
|
+
|
|
20943
21024
|
/**
|
|
20944
21025
|
* Base class containing the logic of interaction WebMap with NextGIS services.
|
|
20945
21026
|
*
|
|
@@ -20958,7 +21039,6 @@ function prepareWebMapOptions(options) {
|
|
|
20958
21039
|
* webmapId: 3985
|
|
20959
21040
|
* });
|
|
20960
21041
|
* ```
|
|
20961
|
-
* @public
|
|
20962
21042
|
*/
|
|
20963
21043
|
class NgwMap extends WebMap {
|
|
20964
21044
|
constructor(options) {
|
|
@@ -21035,7 +21115,7 @@ class NgwMap extends WebMap {
|
|
|
21035
21115
|
options.adapterOptions.setViewDelay = this.options.setViewDelay;
|
|
21036
21116
|
}
|
|
21037
21117
|
}
|
|
21038
|
-
const adapter =
|
|
21118
|
+
const adapter = createNgwLayerAdapter(options, this, this.connector);
|
|
21039
21119
|
const adapterOpts = {
|
|
21040
21120
|
visibility: true,
|
|
21041
21121
|
// TODO: do not merge options, use only `adapterOptions`
|
|
@@ -21182,10 +21262,10 @@ class NgwMap extends WebMap {
|
|
|
21182
21262
|
}
|
|
21183
21263
|
const ngwLayer = id && this._ngwLayers[id];
|
|
21184
21264
|
if (ngwLayer) {
|
|
21185
|
-
if (ngwLayer.layer.
|
|
21186
|
-
const
|
|
21187
|
-
if (
|
|
21188
|
-
this.fitBounds(
|
|
21265
|
+
if (ngwLayer.layer.getBounds) {
|
|
21266
|
+
const bounds = await ngwLayer.layer.getBounds();
|
|
21267
|
+
if (bounds) {
|
|
21268
|
+
this.fitBounds(bounds, options);
|
|
21189
21269
|
}
|
|
21190
21270
|
}
|
|
21191
21271
|
else {
|
|
@@ -21316,10 +21396,10 @@ class NgwMap extends WebMap {
|
|
|
21316
21396
|
async _createWebMap() {
|
|
21317
21397
|
await this.create();
|
|
21318
21398
|
if (this.options.qmsId) {
|
|
21319
|
-
this.
|
|
21399
|
+
this._addQmsBaseLayer();
|
|
21320
21400
|
}
|
|
21321
21401
|
if (this.options.osm) {
|
|
21322
|
-
this.
|
|
21402
|
+
this._addOsmBaseLayer();
|
|
21323
21403
|
}
|
|
21324
21404
|
const resources = [];
|
|
21325
21405
|
const layerFitAllowed = this._isFitFromResource();
|
|
@@ -21348,10 +21428,10 @@ class NgwMap extends WebMap {
|
|
|
21348
21428
|
this._emitStatusEvent('ngw-map:create', this);
|
|
21349
21429
|
this.enableSelection();
|
|
21350
21430
|
}
|
|
21351
|
-
|
|
21431
|
+
_addOsmBaseLayer() {
|
|
21352
21432
|
this.addBaseLayer('OSM');
|
|
21353
21433
|
}
|
|
21354
|
-
|
|
21434
|
+
_addQmsBaseLayer() {
|
|
21355
21435
|
let qmsId;
|
|
21356
21436
|
let qmsLayerName;
|
|
21357
21437
|
if (Array.isArray(this.options.qmsId)) {
|
|
@@ -21441,9 +21521,7 @@ class NgwMap extends WebMap {
|
|
|
21441
21521
|
this._emitStatusEvent('ngw:select', null);
|
|
21442
21522
|
return;
|
|
21443
21523
|
}
|
|
21444
|
-
const
|
|
21445
|
-
Math.pow(2, zoom + 8);
|
|
21446
|
-
const radius = pixelRadius * metresPerPixel * 0.0005;
|
|
21524
|
+
const radius = getIdentifyRadius(center, zoom, pixelRadius);
|
|
21447
21525
|
const selectPromise = sendIdentifyRequest(ev, {
|
|
21448
21526
|
layers: ids,
|
|
21449
21527
|
connector: this.connector,
|
|
@@ -21486,79 +21564,6 @@ class NgwMap extends WebMap {
|
|
|
21486
21564
|
}
|
|
21487
21565
|
NgwMap.getIcon = getIcon;
|
|
21488
21566
|
|
|
21489
|
-
const typeAlias = {
|
|
21490
|
-
Point: 'point',
|
|
21491
|
-
LineString: 'line',
|
|
21492
|
-
MultiPoint: 'point',
|
|
21493
|
-
Polygon: 'polygon',
|
|
21494
|
-
MultiLineString: 'line',
|
|
21495
|
-
MultiPolygon: 'polygon',
|
|
21496
|
-
GeometryCollection: 'polygon',
|
|
21497
|
-
};
|
|
21498
|
-
const PAINT = {
|
|
21499
|
-
stroke: false,
|
|
21500
|
-
opacity: 1,
|
|
21501
|
-
};
|
|
21502
|
-
const backAliases = {};
|
|
21503
|
-
for (const a in typeAlias) {
|
|
21504
|
-
const layerType = typeAlias[a];
|
|
21505
|
-
const backAlias = backAliases[layerType] || [];
|
|
21506
|
-
backAlias.push(a);
|
|
21507
|
-
backAliases[layerType] = backAlias;
|
|
21508
|
-
}
|
|
21509
|
-
function findMostFrequentGeomType(arr) {
|
|
21510
|
-
const counts = {};
|
|
21511
|
-
for (let fry = 0; fry < arr.length; fry++) {
|
|
21512
|
-
counts[arr[fry]] = 1 + (counts[arr[fry]] || 0);
|
|
21513
|
-
}
|
|
21514
|
-
let maxName = '';
|
|
21515
|
-
for (const c in counts) {
|
|
21516
|
-
const maxCount = maxName ? counts[maxName] : 0;
|
|
21517
|
-
if (counts[c] > maxCount) {
|
|
21518
|
-
maxName = c;
|
|
21519
|
-
}
|
|
21520
|
-
}
|
|
21521
|
-
return maxName;
|
|
21522
|
-
}
|
|
21523
|
-
function detectType(geojson) {
|
|
21524
|
-
let geometry;
|
|
21525
|
-
if (geojson.type === 'FeatureCollection') {
|
|
21526
|
-
const featuresTypes = geojson.features.map((f) => f.geometry.type);
|
|
21527
|
-
geometry = findMostFrequentGeomType(featuresTypes);
|
|
21528
|
-
}
|
|
21529
|
-
else if (geojson.type === 'GeometryCollection') {
|
|
21530
|
-
const geometryTypes = geojson.geometries.map((g) => g.type);
|
|
21531
|
-
geometry = findMostFrequentGeomType(geometryTypes);
|
|
21532
|
-
}
|
|
21533
|
-
else if (geojson.type === 'Feature') {
|
|
21534
|
-
geometry = geojson.geometry.type;
|
|
21535
|
-
}
|
|
21536
|
-
else {
|
|
21537
|
-
geometry = geojson.type;
|
|
21538
|
-
}
|
|
21539
|
-
return geometry;
|
|
21540
|
-
}
|
|
21541
|
-
function geometryFilter(geometry, type) {
|
|
21542
|
-
const geoJsonGeometry = backAliases[type] || [];
|
|
21543
|
-
return geoJsonGeometry.indexOf(geometry) !== -1;
|
|
21544
|
-
}
|
|
21545
|
-
function filterGeometries(data, type) {
|
|
21546
|
-
if (data.type === 'FeatureCollection') {
|
|
21547
|
-
const _data = data;
|
|
21548
|
-
_data.features = _data.features.filter((f) => geometryFilter(f.geometry.type, type));
|
|
21549
|
-
}
|
|
21550
|
-
else if (data.type === 'Feature') {
|
|
21551
|
-
const allow = geometryFilter(data.geometry.type, type);
|
|
21552
|
-
if (!allow) {
|
|
21553
|
-
return false;
|
|
21554
|
-
}
|
|
21555
|
-
}
|
|
21556
|
-
else if (data.type === 'GeometryCollection') {
|
|
21557
|
-
const _data = data;
|
|
21558
|
-
_data.geometries = _data.geometries.filter((g) => geometryFilter(g.type, type));
|
|
21559
|
-
}
|
|
21560
|
-
return data;
|
|
21561
|
-
}
|
|
21562
21567
|
function convertMapClickEvent(evt) {
|
|
21563
21568
|
const coord = evt.containerPoint;
|
|
21564
21569
|
const latLng = evt.latlng;
|
|
@@ -21655,6 +21660,119 @@ class AttributionControl extends leafletSrc.exports.Control.Attribution {
|
|
|
21655
21660
|
}
|
|
21656
21661
|
}
|
|
21657
21662
|
|
|
21663
|
+
function boundsToArray(bounds) {
|
|
21664
|
+
const ne = bounds.getNorthEast();
|
|
21665
|
+
const sw = bounds.getSouthWest();
|
|
21666
|
+
return [sw.lng, sw.lat, ne.lng, ne.lat];
|
|
21667
|
+
}
|
|
21668
|
+
|
|
21669
|
+
const typeAlias = {
|
|
21670
|
+
Point: 'point',
|
|
21671
|
+
LineString: 'line',
|
|
21672
|
+
MultiPoint: 'point',
|
|
21673
|
+
Polygon: 'polygon',
|
|
21674
|
+
MultiLineString: 'line',
|
|
21675
|
+
MultiPolygon: 'polygon',
|
|
21676
|
+
GeometryCollection: 'polygon',
|
|
21677
|
+
};
|
|
21678
|
+
const PAINT = {
|
|
21679
|
+
stroke: false,
|
|
21680
|
+
opacity: 1,
|
|
21681
|
+
};
|
|
21682
|
+
const backAliases = {};
|
|
21683
|
+
for (const a in typeAlias) {
|
|
21684
|
+
const layerType = typeAlias[a];
|
|
21685
|
+
const backAlias = backAliases[layerType] || [];
|
|
21686
|
+
backAlias.push(a);
|
|
21687
|
+
backAliases[layerType] = backAlias;
|
|
21688
|
+
}
|
|
21689
|
+
function geometryFilter(geometry, type) {
|
|
21690
|
+
const geoJsonGeometry = backAliases[type] || [];
|
|
21691
|
+
return geoJsonGeometry.indexOf(geometry) !== -1;
|
|
21692
|
+
}
|
|
21693
|
+
function filterGeometries(data, type) {
|
|
21694
|
+
if (data.type === 'FeatureCollection') {
|
|
21695
|
+
const _data = data;
|
|
21696
|
+
_data.features = _data.features.filter((f) => geometryFilter(f.geometry.type, type));
|
|
21697
|
+
}
|
|
21698
|
+
else if (data.type === 'Feature') {
|
|
21699
|
+
const allow = geometryFilter(data.geometry.type, type);
|
|
21700
|
+
if (!allow) {
|
|
21701
|
+
return false;
|
|
21702
|
+
}
|
|
21703
|
+
}
|
|
21704
|
+
else if (data.type === 'GeometryCollection') {
|
|
21705
|
+
const _data = data;
|
|
21706
|
+
_data.geometries = _data.geometries.filter((g) => geometryFilter(g.type, type));
|
|
21707
|
+
}
|
|
21708
|
+
return data;
|
|
21709
|
+
}
|
|
21710
|
+
function featuresBounds(features) {
|
|
21711
|
+
const geoJsonLayer = new leafletSrc.exports.GeoJSON();
|
|
21712
|
+
const features_ = Array.isArray(features) ? features : [features];
|
|
21713
|
+
features_.forEach((f) => geoJsonLayer.addData(f));
|
|
21714
|
+
return geoJsonLayer.getBounds();
|
|
21715
|
+
}
|
|
21716
|
+
function getFeaturesBounds(features) {
|
|
21717
|
+
return boundsToArray(featuresBounds(features));
|
|
21718
|
+
}
|
|
21719
|
+
function getFeaturesCenter(features) {
|
|
21720
|
+
const { lat, lng } = featuresBounds(features).getCenter();
|
|
21721
|
+
return [lng, lat];
|
|
21722
|
+
}
|
|
21723
|
+
function createFeaturePositionOptions(features) {
|
|
21724
|
+
return {
|
|
21725
|
+
getBounds: () => getFeaturesBounds(features),
|
|
21726
|
+
getCenter: () => getFeaturesCenter(features),
|
|
21727
|
+
};
|
|
21728
|
+
}
|
|
21729
|
+
|
|
21730
|
+
function createMouseEvent({ layer, source, }) {
|
|
21731
|
+
const layer_ = source.target;
|
|
21732
|
+
const feature = layer_.feature;
|
|
21733
|
+
const opt = {
|
|
21734
|
+
layer,
|
|
21735
|
+
feature,
|
|
21736
|
+
event: convertMapClickEvent(source),
|
|
21737
|
+
source,
|
|
21738
|
+
...createFeaturePositionOptions(feature),
|
|
21739
|
+
};
|
|
21740
|
+
return opt;
|
|
21741
|
+
}
|
|
21742
|
+
|
|
21743
|
+
function findMostFrequentGeomType(arr) {
|
|
21744
|
+
const counts = {};
|
|
21745
|
+
for (let fry = 0; fry < arr.length; fry++) {
|
|
21746
|
+
counts[arr[fry]] = 1 + (counts[arr[fry]] || 0);
|
|
21747
|
+
}
|
|
21748
|
+
let maxName = '';
|
|
21749
|
+
for (const c in counts) {
|
|
21750
|
+
const maxCount = maxName ? counts[maxName] : 0;
|
|
21751
|
+
if (counts[c] > maxCount) {
|
|
21752
|
+
maxName = c;
|
|
21753
|
+
}
|
|
21754
|
+
}
|
|
21755
|
+
return maxName;
|
|
21756
|
+
}
|
|
21757
|
+
function detectType(geojson) {
|
|
21758
|
+
let geometry;
|
|
21759
|
+
if (geojson.type === 'FeatureCollection') {
|
|
21760
|
+
const featuresTypes = geojson.features.map((f) => f.geometry.type);
|
|
21761
|
+
geometry = findMostFrequentGeomType(featuresTypes);
|
|
21762
|
+
}
|
|
21763
|
+
else if (geojson.type === 'GeometryCollection') {
|
|
21764
|
+
const geometryTypes = geojson.geometries.map((g) => g.type);
|
|
21765
|
+
geometry = findMostFrequentGeomType(geometryTypes);
|
|
21766
|
+
}
|
|
21767
|
+
else if (geojson.type === 'Feature') {
|
|
21768
|
+
geometry = geojson.geometry.type;
|
|
21769
|
+
}
|
|
21770
|
+
else {
|
|
21771
|
+
geometry = geojson.type;
|
|
21772
|
+
}
|
|
21773
|
+
return geometry;
|
|
21774
|
+
}
|
|
21775
|
+
|
|
21658
21776
|
class BaseAdapter {
|
|
21659
21777
|
constructor(map, options) {
|
|
21660
21778
|
this.map = map;
|
|
@@ -21670,7 +21788,8 @@ class BaseAdapter {
|
|
|
21670
21788
|
this.pane = pane;
|
|
21671
21789
|
}
|
|
21672
21790
|
}
|
|
21673
|
-
addLayer(
|
|
21791
|
+
addLayer(options) {
|
|
21792
|
+
Object.assign(this.options, options);
|
|
21674
21793
|
return undefined;
|
|
21675
21794
|
}
|
|
21676
21795
|
}
|
|
@@ -21689,11 +21808,14 @@ class GeoJsonAdapter extends BaseAdapter {
|
|
|
21689
21808
|
this.$unselect = () => {
|
|
21690
21809
|
this.unselect();
|
|
21691
21810
|
};
|
|
21692
|
-
this.layer = new leafletSrc.exports.FeatureGroup([], { pane: this.pane });
|
|
21693
21811
|
}
|
|
21694
21812
|
addLayer(options) {
|
|
21695
|
-
this.options
|
|
21813
|
+
Object.assign(this.options, options);
|
|
21696
21814
|
this.paint = options.paint;
|
|
21815
|
+
this.layer = new leafletSrc.exports.FeatureGroup([], {
|
|
21816
|
+
...options.nativeOptions,
|
|
21817
|
+
pane: this.pane,
|
|
21818
|
+
});
|
|
21697
21819
|
this.selectedPaint = options.selectedPaint;
|
|
21698
21820
|
options.paint = this.paint;
|
|
21699
21821
|
if (options.data) {
|
|
@@ -21739,7 +21861,12 @@ class GeoJsonAdapter extends BaseAdapter {
|
|
|
21739
21861
|
}
|
|
21740
21862
|
getSelected() {
|
|
21741
21863
|
return this._selectedLayers.map((x) => {
|
|
21742
|
-
return {
|
|
21864
|
+
return {
|
|
21865
|
+
target: this,
|
|
21866
|
+
feature: x.feature,
|
|
21867
|
+
layer: x,
|
|
21868
|
+
...createFeaturePositionOptions(x.feature),
|
|
21869
|
+
};
|
|
21743
21870
|
});
|
|
21744
21871
|
}
|
|
21745
21872
|
getFiltered() {
|
|
@@ -21748,27 +21875,37 @@ class GeoJsonAdapter extends BaseAdapter {
|
|
|
21748
21875
|
filter(fun) {
|
|
21749
21876
|
// Some optimization
|
|
21750
21877
|
this._filterFun = fun;
|
|
21751
|
-
|
|
21752
|
-
const
|
|
21753
|
-
if (
|
|
21754
|
-
|
|
21755
|
-
|
|
21756
|
-
|
|
21757
|
-
|
|
21758
|
-
|
|
21759
|
-
|
|
21760
|
-
|
|
21761
|
-
|
|
21762
|
-
|
|
21763
|
-
|
|
21764
|
-
|
|
21765
|
-
|
|
21878
|
+
const layer_ = this.layer;
|
|
21879
|
+
const map = layer_ && layer_._map;
|
|
21880
|
+
if (layer_ && map) {
|
|
21881
|
+
layer_.remove();
|
|
21882
|
+
const filteredLayers = [];
|
|
21883
|
+
this._layers.forEach(({ feature, layer }) => {
|
|
21884
|
+
if (layer) {
|
|
21885
|
+
const ok = fun
|
|
21886
|
+
? fun({
|
|
21887
|
+
target: this,
|
|
21888
|
+
feature,
|
|
21889
|
+
layer,
|
|
21890
|
+
...createFeaturePositionOptions(feature),
|
|
21891
|
+
})
|
|
21892
|
+
: true;
|
|
21893
|
+
if (ok) {
|
|
21894
|
+
layer_.addLayer(layer);
|
|
21895
|
+
filteredLayers.push({
|
|
21896
|
+
target: this,
|
|
21897
|
+
feature,
|
|
21898
|
+
layer,
|
|
21899
|
+
...createFeaturePositionOptions(feature),
|
|
21900
|
+
});
|
|
21901
|
+
}
|
|
21902
|
+
else {
|
|
21903
|
+
layer_.removeLayer(layer);
|
|
21904
|
+
}
|
|
21766
21905
|
}
|
|
21767
|
-
}
|
|
21768
|
-
|
|
21769
|
-
|
|
21770
|
-
if (_map) {
|
|
21771
|
-
this.layer.addTo(_map);
|
|
21906
|
+
});
|
|
21907
|
+
this._filteredLayers = filteredLayers;
|
|
21908
|
+
layer_.addTo(map);
|
|
21772
21909
|
}
|
|
21773
21910
|
return this._filteredLayers;
|
|
21774
21911
|
}
|
|
@@ -21783,29 +21920,33 @@ class GeoJsonAdapter extends BaseAdapter {
|
|
|
21783
21920
|
layer,
|
|
21784
21921
|
visible,
|
|
21785
21922
|
target: this,
|
|
21923
|
+
...createFeaturePositionOptions(feature),
|
|
21786
21924
|
};
|
|
21787
21925
|
});
|
|
21788
21926
|
}
|
|
21789
21927
|
clearLayer(cb) {
|
|
21790
21928
|
this.unselect();
|
|
21791
|
-
|
|
21792
|
-
|
|
21793
|
-
|
|
21794
|
-
|
|
21795
|
-
const
|
|
21796
|
-
if (
|
|
21797
|
-
const
|
|
21798
|
-
if (
|
|
21799
|
-
|
|
21800
|
-
|
|
21929
|
+
const layer_ = this.layer;
|
|
21930
|
+
if (layer_) {
|
|
21931
|
+
if (cb) {
|
|
21932
|
+
for (let fry = this._layers.length; fry--;) {
|
|
21933
|
+
const def = this._layers[fry];
|
|
21934
|
+
if (def) {
|
|
21935
|
+
const { feature, layer } = def;
|
|
21936
|
+
if (feature && layer) {
|
|
21937
|
+
const exist = cb(feature);
|
|
21938
|
+
if (exist) {
|
|
21939
|
+
layer_.removeLayer(layer);
|
|
21940
|
+
this._layers.splice(fry, 1);
|
|
21941
|
+
}
|
|
21801
21942
|
}
|
|
21802
21943
|
}
|
|
21803
21944
|
}
|
|
21804
21945
|
}
|
|
21805
|
-
|
|
21806
|
-
|
|
21807
|
-
|
|
21808
|
-
|
|
21946
|
+
else {
|
|
21947
|
+
layer_.clearLayers();
|
|
21948
|
+
this._layers = [];
|
|
21949
|
+
}
|
|
21809
21950
|
}
|
|
21810
21951
|
}
|
|
21811
21952
|
setData(data) {
|
|
@@ -21862,12 +22003,14 @@ class GeoJsonAdapter extends BaseAdapter {
|
|
|
21862
22003
|
this.getLayers().forEach((x) => this._updateTooltip({ feature: x.feature, layer: x.layer }));
|
|
21863
22004
|
}
|
|
21864
22005
|
}
|
|
22006
|
+
/** @deprecated use {@link GeoJsonAdapter.getBounds} instead */
|
|
21865
22007
|
getExtent() {
|
|
21866
|
-
|
|
21867
|
-
|
|
21868
|
-
|
|
21869
|
-
if (
|
|
21870
|
-
|
|
22008
|
+
return this.getBounds();
|
|
22009
|
+
}
|
|
22010
|
+
getBounds() {
|
|
22011
|
+
if (this.layer) {
|
|
22012
|
+
const bounds = this.layer.getBounds();
|
|
22013
|
+
return boundsToArray(bounds);
|
|
21871
22014
|
}
|
|
21872
22015
|
}
|
|
21873
22016
|
setOpacity(value) {
|
|
@@ -21937,6 +22080,7 @@ class GeoJsonAdapter extends BaseAdapter {
|
|
|
21937
22080
|
type,
|
|
21938
22081
|
close,
|
|
21939
22082
|
onClose,
|
|
22083
|
+
...createFeaturePositionOptions(feature),
|
|
21940
22084
|
})
|
|
21941
22085
|
: options.popupContent;
|
|
21942
22086
|
if (content && layer) {
|
|
@@ -22082,25 +22226,38 @@ class GeoJsonAdapter extends BaseAdapter {
|
|
|
22082
22226
|
lopt = this._createPaintOptions(paint, type);
|
|
22083
22227
|
}
|
|
22084
22228
|
lopt.onEachFeature = (feature, layer) => {
|
|
22229
|
+
this._onEachFeature(feature, layer);
|
|
22230
|
+
};
|
|
22231
|
+
return lopt;
|
|
22232
|
+
}
|
|
22233
|
+
_onEachFeature(feature, layer) {
|
|
22234
|
+
const layer_ = this.layer;
|
|
22235
|
+
if (layer_) {
|
|
22236
|
+
const def = {
|
|
22237
|
+
target: this,
|
|
22238
|
+
feature,
|
|
22239
|
+
layer,
|
|
22240
|
+
...createFeaturePositionOptions(feature),
|
|
22241
|
+
};
|
|
22085
22242
|
// @ts-ignore
|
|
22086
22243
|
layer.options.pane = this.pane;
|
|
22087
|
-
this._layers.push(
|
|
22244
|
+
this._layers.push(def);
|
|
22088
22245
|
let ok = true;
|
|
22089
22246
|
if (this._filterFun) {
|
|
22090
|
-
ok = this._filterFun(
|
|
22247
|
+
ok = this._filterFun(def);
|
|
22091
22248
|
}
|
|
22092
22249
|
if (ok) {
|
|
22093
22250
|
const { popup, popupOptions, selectable, interactive, selectOnHover } = this.options;
|
|
22094
22251
|
// @ts-ignore
|
|
22095
22252
|
layer.options.interactive = defined(interactive) ? interactive : true;
|
|
22096
|
-
|
|
22253
|
+
layer_.addLayer(layer);
|
|
22097
22254
|
if (selectable) {
|
|
22098
22255
|
if (selectOnHover) {
|
|
22099
22256
|
layer.on('mouseover', () => {
|
|
22100
|
-
this._selectLayer(
|
|
22257
|
+
this._selectLayer(def, 'hover');
|
|
22101
22258
|
});
|
|
22102
22259
|
layer.on('mouseout', () => {
|
|
22103
|
-
this._unSelectLayer(
|
|
22260
|
+
this._unSelectLayer(def);
|
|
22104
22261
|
});
|
|
22105
22262
|
}
|
|
22106
22263
|
else {
|
|
@@ -22109,24 +22266,19 @@ class GeoJsonAdapter extends BaseAdapter {
|
|
|
22109
22266
|
}
|
|
22110
22267
|
this._handleMouseEvents(layer);
|
|
22111
22268
|
if (popup) {
|
|
22112
|
-
this._openPopup({
|
|
22269
|
+
this._openPopup({
|
|
22270
|
+
target: this,
|
|
22271
|
+
layer,
|
|
22272
|
+
feature,
|
|
22273
|
+
...createFeaturePositionOptions(feature),
|
|
22274
|
+
}, popupOptions, 'api');
|
|
22113
22275
|
}
|
|
22114
22276
|
this._updateTooltip({ layer, feature });
|
|
22115
22277
|
}
|
|
22116
|
-
}
|
|
22117
|
-
return lopt;
|
|
22278
|
+
}
|
|
22118
22279
|
}
|
|
22119
22280
|
_handleMouseEvents(layer) {
|
|
22120
22281
|
const isSelected = (l) => this._selectedLayers.indexOf(l) !== -1;
|
|
22121
|
-
const createMouseOptions = (e) => {
|
|
22122
|
-
const layer_ = e.target;
|
|
22123
|
-
return {
|
|
22124
|
-
layer: this,
|
|
22125
|
-
feature: layer_.feature,
|
|
22126
|
-
event: convertMapClickEvent(e),
|
|
22127
|
-
source: e,
|
|
22128
|
-
};
|
|
22129
|
-
};
|
|
22130
22282
|
const { onClick, onLayerClick, onMouseOut, onMouseOver } = this.options;
|
|
22131
22283
|
// TODO: remove backward compatibility for onLayerClick
|
|
22132
22284
|
const onClick_ = onClick || onLayerClick;
|
|
@@ -22134,25 +22286,37 @@ class GeoJsonAdapter extends BaseAdapter {
|
|
|
22134
22286
|
layer.on('click', (e) => {
|
|
22135
22287
|
onClick_({
|
|
22136
22288
|
selected: isSelected(e.target),
|
|
22137
|
-
...
|
|
22289
|
+
...this._createMouseEvent(e),
|
|
22138
22290
|
});
|
|
22139
22291
|
}, this);
|
|
22140
22292
|
}
|
|
22141
22293
|
if (onMouseOut) {
|
|
22142
22294
|
layer.on('mouseout', (e) => {
|
|
22143
|
-
onMouseOut(
|
|
22295
|
+
onMouseOut(this._createMouseEvent(e));
|
|
22144
22296
|
}, this);
|
|
22145
22297
|
}
|
|
22146
22298
|
if (onMouseOver) {
|
|
22147
22299
|
layer.on('mouseover', (e) => {
|
|
22148
|
-
onMouseOver(
|
|
22300
|
+
onMouseOver(this._createMouseEvent(e));
|
|
22149
22301
|
}, this);
|
|
22150
22302
|
}
|
|
22151
22303
|
}
|
|
22304
|
+
_createMouseEvent(source) {
|
|
22305
|
+
return createMouseEvent({
|
|
22306
|
+
layer: this,
|
|
22307
|
+
source: source,
|
|
22308
|
+
});
|
|
22309
|
+
}
|
|
22152
22310
|
_selectOnLayerClick(e) {
|
|
22153
22311
|
leafletSrc.exports.DomEvent.stopPropagation(e);
|
|
22154
22312
|
const layer = e.target;
|
|
22155
|
-
const
|
|
22313
|
+
const feature = layer.feature;
|
|
22314
|
+
const def = {
|
|
22315
|
+
target: this,
|
|
22316
|
+
layer,
|
|
22317
|
+
feature,
|
|
22318
|
+
...createFeaturePositionOptions(feature),
|
|
22319
|
+
};
|
|
22156
22320
|
const isSelected = this._selectedLayers.find((x) => x.layer === layer);
|
|
22157
22321
|
if (isSelected) {
|
|
22158
22322
|
if (this.options && this.options.unselectOnSecondClick) {
|
|
@@ -22180,10 +22344,12 @@ class GeoJsonAdapter extends BaseAdapter {
|
|
|
22180
22344
|
this._openPopup(def, popupOptions, type, latlng);
|
|
22181
22345
|
}
|
|
22182
22346
|
if (this.options.onSelect) {
|
|
22347
|
+
const features = def.feature ? [def.feature] : [];
|
|
22183
22348
|
this.options.onSelect({
|
|
22184
22349
|
type,
|
|
22185
22350
|
layer: this,
|
|
22186
|
-
features
|
|
22351
|
+
features,
|
|
22352
|
+
...createFeaturePositionOptions(features),
|
|
22187
22353
|
});
|
|
22188
22354
|
}
|
|
22189
22355
|
}
|
|
@@ -22513,7 +22679,6 @@ class ImageLayer extends leafletSrc.exports.Layer {
|
|
|
22513
22679
|
}
|
|
22514
22680
|
}
|
|
22515
22681
|
|
|
22516
|
-
// @ts-ignore
|
|
22517
22682
|
class ImageAdapter extends BaseAdapter {
|
|
22518
22683
|
addLayer(options) {
|
|
22519
22684
|
const url = options && options.url;
|
|
@@ -22525,10 +22690,11 @@ class ImageAdapter extends BaseAdapter {
|
|
|
22525
22690
|
headers: options.headers,
|
|
22526
22691
|
setViewDelay: options.setViewDelay,
|
|
22527
22692
|
/**
|
|
22528
|
-
* TODO: safe remove, use only options.
|
|
22693
|
+
* TODO: safe remove, use only options.nativeOptions
|
|
22529
22694
|
*/
|
|
22530
22695
|
...options,
|
|
22531
22696
|
...options.params,
|
|
22697
|
+
...options.nativeOptions,
|
|
22532
22698
|
});
|
|
22533
22699
|
if (updateWmsParamsFromOpt) {
|
|
22534
22700
|
const updateWmsParams = this.layer.updateWmsParams;
|
|
@@ -22647,33 +22813,33 @@ const WmsLayer = makeRemote(WmsLayerBase);
|
|
|
22647
22813
|
|
|
22648
22814
|
class WmsAdapter extends BaseAdapter {
|
|
22649
22815
|
addLayer(options) {
|
|
22650
|
-
|
|
22651
|
-
|
|
22652
|
-
|
|
22653
|
-
|
|
22654
|
-
|
|
22655
|
-
|
|
22656
|
-
|
|
22657
|
-
|
|
22658
|
-
|
|
22659
|
-
|
|
22660
|
-
|
|
22661
|
-
|
|
22662
|
-
|
|
22663
|
-
|
|
22664
|
-
}
|
|
22665
|
-
else {
|
|
22666
|
-
layer = new leafletSrc.exports.TileLayer.WMS(url, layerOptions);
|
|
22667
|
-
}
|
|
22668
|
-
return layer;
|
|
22816
|
+
Object.assign(this.options, options);
|
|
22817
|
+
const { url, ...opt } = options;
|
|
22818
|
+
if (url) {
|
|
22819
|
+
const layerOptions = {
|
|
22820
|
+
pane: this.pane,
|
|
22821
|
+
attribution: opt.attribution,
|
|
22822
|
+
minZoom: opt.minZoom,
|
|
22823
|
+
maxZoom: opt.maxZoom,
|
|
22824
|
+
layers: options.layers,
|
|
22825
|
+
format: options.format,
|
|
22826
|
+
...options.nativeOptions,
|
|
22827
|
+
};
|
|
22828
|
+
let layer;
|
|
22829
|
+
if (opt.headers) {
|
|
22830
|
+
layer = new WmsLayer(url, { ...layerOptions, headers: opt.headers });
|
|
22669
22831
|
}
|
|
22832
|
+
else {
|
|
22833
|
+
layer = new leafletSrc.exports.TileLayer.WMS(url, layerOptions);
|
|
22834
|
+
}
|
|
22835
|
+
return layer;
|
|
22670
22836
|
}
|
|
22671
22837
|
}
|
|
22672
22838
|
}
|
|
22673
22839
|
|
|
22674
22840
|
class OsmAdapter extends TileAdapter {
|
|
22675
22841
|
addLayer(options) {
|
|
22676
|
-
const url =
|
|
22842
|
+
const url = 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
|
|
22677
22843
|
return super.addLayer({
|
|
22678
22844
|
name: 'OpenStreetMap',
|
|
22679
22845
|
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
|
|
@@ -22972,3 +23138,4 @@ if (window && !window.NgwMap) {
|
|
|
22972
23138
|
}
|
|
22973
23139
|
|
|
22974
23140
|
export { NgwLeaflet as default };
|
|
23141
|
+
//# sourceMappingURL=ngw-leaflet.esm-browser.js.map
|