@nextgis/ngw-leaflet 1.8.0 → 1.8.4
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/README.md +1 -1
- package/lib/ngw-leaflet.esm-browser.js +156 -66
- 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 +244 -90
- 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 +5 -5
package/README.md
CHANGED
|
@@ -66,7 +66,7 @@ const ngwMap = new NgwMap({
|
|
|
66
66
|
});
|
|
67
67
|
```
|
|
68
68
|
|
|
69
|
-
Check out the [API Documentation](https://
|
|
69
|
+
Check out the [API Documentation](https://code-api.nextgis.com/modules/ngw_map.html)
|
|
70
70
|
|
|
71
71
|
## Commercial support
|
|
72
72
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Bundle of @nextgis/ngw-leaflet; version: 1.8.
|
|
1
|
+
/** Bundle of @nextgis/ngw-leaflet; version: 1.8.4; author: NextGIS */
|
|
2
2
|
function styleInject(css, ref) {
|
|
3
3
|
if ( ref === void 0 ) ref = {};
|
|
4
4
|
var insertAt = ref.insertAt;
|
|
@@ -16682,10 +16682,10 @@ class WebMapLayers extends WebMapMain {
|
|
|
16682
16682
|
}
|
|
16683
16683
|
}
|
|
16684
16684
|
if (l.showLayer) {
|
|
16685
|
-
l.showLayer.call(l, l.layer);
|
|
16685
|
+
await l.showLayer.call(l, l.layer);
|
|
16686
16686
|
}
|
|
16687
16687
|
else if (l.layer !== undefined) {
|
|
16688
|
-
this.mapAdapter.showLayer(l.layer);
|
|
16688
|
+
await this.mapAdapter.showLayer(l.layer);
|
|
16689
16689
|
}
|
|
16690
16690
|
if (order !== undefined) {
|
|
16691
16691
|
this.mapAdapter.setLayerOrder(l.layer, order, this._layers);
|
|
@@ -16693,10 +16693,10 @@ class WebMapLayers extends WebMapMain {
|
|
|
16693
16693
|
}
|
|
16694
16694
|
else {
|
|
16695
16695
|
if (l.hideLayer) {
|
|
16696
|
-
l.hideLayer.call(l, l.layer);
|
|
16696
|
+
await l.hideLayer.call(l, l.layer);
|
|
16697
16697
|
}
|
|
16698
16698
|
else if (l.layer !== undefined) {
|
|
16699
|
-
this.mapAdapter.hideLayer(l.layer);
|
|
16699
|
+
await this.mapAdapter.hideLayer(l.layer);
|
|
16700
16700
|
}
|
|
16701
16701
|
}
|
|
16702
16702
|
if (!silent) {
|
|
@@ -16714,13 +16714,15 @@ class WebMapLayers extends WebMapMain {
|
|
|
16714
16714
|
const layer = this.getLayer(layerDef);
|
|
16715
16715
|
if (layer) {
|
|
16716
16716
|
if (layer.updateLayer) {
|
|
16717
|
-
layer.updateLayer();
|
|
16717
|
+
return Promise.resolve(layer.updateLayer());
|
|
16718
16718
|
}
|
|
16719
16719
|
else if (this.isLayerVisible(layer)) {
|
|
16720
|
-
this.hideLayer(layer, { silent: true })
|
|
16721
|
-
|
|
16720
|
+
return this.hideLayer(layer, { silent: true }).then(() => {
|
|
16721
|
+
return this.showLayer(layer, { silent: true });
|
|
16722
|
+
});
|
|
16722
16723
|
}
|
|
16723
16724
|
}
|
|
16725
|
+
return Promise.resolve();
|
|
16724
16726
|
}
|
|
16725
16727
|
/**
|
|
16726
16728
|
* Set transparency for a given layer by number from 0 to 1
|
|
@@ -19294,6 +19296,9 @@ class BaseProperty {
|
|
|
19294
19296
|
getParent() {
|
|
19295
19297
|
return this.item.tree.getParent();
|
|
19296
19298
|
}
|
|
19299
|
+
getChildren() {
|
|
19300
|
+
return this.item.tree.getChildren();
|
|
19301
|
+
}
|
|
19297
19302
|
isGroup() {
|
|
19298
19303
|
const children = this.item.tree.getDescendants();
|
|
19299
19304
|
return children.length;
|
|
@@ -19408,6 +19413,24 @@ class CheckProperty extends BaseProperty {
|
|
|
19408
19413
|
return property && property.get();
|
|
19409
19414
|
}));
|
|
19410
19415
|
}
|
|
19416
|
+
block(options) {
|
|
19417
|
+
this._blocked = true;
|
|
19418
|
+
this._block(options);
|
|
19419
|
+
}
|
|
19420
|
+
unBlock(options) {
|
|
19421
|
+
this._blocked = false;
|
|
19422
|
+
if (this.getValue()) {
|
|
19423
|
+
this._unBlock(options);
|
|
19424
|
+
}
|
|
19425
|
+
}
|
|
19426
|
+
blockChild(options) {
|
|
19427
|
+
this.item.tree
|
|
19428
|
+
.getDescendants()
|
|
19429
|
+
.forEach((x) => this._blockChild(x, options));
|
|
19430
|
+
}
|
|
19431
|
+
unblockChild(options) {
|
|
19432
|
+
this.item.tree.getChildren().forEach((x) => this._unBlockChild(x, options));
|
|
19433
|
+
}
|
|
19411
19434
|
_prepareValue(value) {
|
|
19412
19435
|
return value;
|
|
19413
19436
|
}
|
|
@@ -19429,30 +19452,12 @@ class CheckProperty extends BaseProperty {
|
|
|
19429
19452
|
this.unblockChild(options);
|
|
19430
19453
|
}
|
|
19431
19454
|
}
|
|
19432
|
-
block(options) {
|
|
19433
|
-
this._blocked = true;
|
|
19434
|
-
this._block(options);
|
|
19435
|
-
}
|
|
19436
19455
|
_block(options) {
|
|
19437
19456
|
this._turnOff(options);
|
|
19438
19457
|
}
|
|
19439
|
-
unBlock(options) {
|
|
19440
|
-
this._blocked = false;
|
|
19441
|
-
if (this.getValue()) {
|
|
19442
|
-
this._unBlock(options);
|
|
19443
|
-
}
|
|
19444
|
-
}
|
|
19445
19458
|
_unBlock(options) {
|
|
19446
19459
|
this._turnOn(options);
|
|
19447
19460
|
}
|
|
19448
|
-
blockChild(options) {
|
|
19449
|
-
this.item.tree
|
|
19450
|
-
.getDescendants()
|
|
19451
|
-
.forEach((x) => this._blockChild(x, options));
|
|
19452
|
-
}
|
|
19453
|
-
unblockChild(options) {
|
|
19454
|
-
this.item.tree.getChildren().forEach((x) => this._unBlockChild(x, options));
|
|
19455
|
-
}
|
|
19456
19461
|
_blockChild(item, options) {
|
|
19457
19462
|
const prop = item.properties &&
|
|
19458
19463
|
item.properties.property(this.name);
|
|
@@ -19510,22 +19515,22 @@ class ItemProperties {
|
|
|
19510
19515
|
}
|
|
19511
19516
|
_setPropertyHandler(propOpt) {
|
|
19512
19517
|
const handlers = ItemProperties.handlers;
|
|
19513
|
-
let
|
|
19514
|
-
if (!
|
|
19518
|
+
let Handler = propOpt.handler;
|
|
19519
|
+
if (!Handler && propOpt.type) {
|
|
19515
19520
|
switch (propOpt.type) {
|
|
19516
19521
|
case 'boolean':
|
|
19517
|
-
|
|
19522
|
+
Handler = handlers.CheckProperty;
|
|
19518
19523
|
break;
|
|
19519
19524
|
case 'string':
|
|
19520
|
-
|
|
19525
|
+
Handler = handlers.BaseProperty;
|
|
19521
19526
|
break;
|
|
19522
19527
|
default:
|
|
19523
|
-
|
|
19528
|
+
Handler = handlers.BaseProperty;
|
|
19524
19529
|
}
|
|
19525
19530
|
}
|
|
19526
|
-
if (
|
|
19531
|
+
if (Handler && propOpt.name) {
|
|
19527
19532
|
const options = { ...(propOpt || {}) };
|
|
19528
|
-
this._properties[propOpt.name] = new
|
|
19533
|
+
this._properties[propOpt.name] = new Handler(propOpt.name, this.item, options);
|
|
19529
19534
|
this._propertiesList.push(propOpt.name);
|
|
19530
19535
|
}
|
|
19531
19536
|
}
|
|
@@ -19581,6 +19586,55 @@ class Item {
|
|
|
19581
19586
|
}
|
|
19582
19587
|
}
|
|
19583
19588
|
|
|
19589
|
+
class WebmapLayerOpacityPropertyHandler extends BaseProperty {
|
|
19590
|
+
getProperty() {
|
|
19591
|
+
const layer = this.item.layer;
|
|
19592
|
+
if (layer) {
|
|
19593
|
+
return layer && layer.options && layer.options.opacity !== undefined
|
|
19594
|
+
? layer.options.opacity
|
|
19595
|
+
: 1;
|
|
19596
|
+
}
|
|
19597
|
+
return 1;
|
|
19598
|
+
}
|
|
19599
|
+
update(value, options) {
|
|
19600
|
+
options = options || {};
|
|
19601
|
+
if (this.isGroup()) {
|
|
19602
|
+
this._value = this._prepareValue(value, options);
|
|
19603
|
+
const children = this.getChildren();
|
|
19604
|
+
for (const child of children) {
|
|
19605
|
+
const property = child.properties.property(this.name);
|
|
19606
|
+
if (property) {
|
|
19607
|
+
if (options.propagation) {
|
|
19608
|
+
property.set(value, options);
|
|
19609
|
+
}
|
|
19610
|
+
else {
|
|
19611
|
+
property.update(property.get(), options);
|
|
19612
|
+
}
|
|
19613
|
+
}
|
|
19614
|
+
}
|
|
19615
|
+
}
|
|
19616
|
+
const layer = this.item.layer;
|
|
19617
|
+
if (layer) {
|
|
19618
|
+
const parents = this.getParents();
|
|
19619
|
+
const coef = parents.reduce((s, x) => {
|
|
19620
|
+
const prop = x.properties.property(this.name);
|
|
19621
|
+
const multiplier = prop ? prop.getValue() : 1;
|
|
19622
|
+
return s * multiplier;
|
|
19623
|
+
}, 1);
|
|
19624
|
+
const val = value * coef;
|
|
19625
|
+
this.item.webMap.setLayerOpacity(layer, this._prepareValue(val));
|
|
19626
|
+
}
|
|
19627
|
+
}
|
|
19628
|
+
_prepareValue(value, options) {
|
|
19629
|
+
if (options && options.propagation && this.isGroup()) {
|
|
19630
|
+
return 1;
|
|
19631
|
+
}
|
|
19632
|
+
// value = Number(value);
|
|
19633
|
+
// return value < 0.1 ? 0.1 : value;
|
|
19634
|
+
return Number(value);
|
|
19635
|
+
}
|
|
19636
|
+
}
|
|
19637
|
+
|
|
19584
19638
|
class NgwWebmapItem extends Item {
|
|
19585
19639
|
constructor(webMap, item, options, connector, parent, noInit) {
|
|
19586
19640
|
super({ ...NgwWebmapItem.options, ...options });
|
|
@@ -19662,6 +19716,9 @@ class NgwWebmapItem extends Item {
|
|
|
19662
19716
|
fit() {
|
|
19663
19717
|
if (this.item.item_type === 'layer') ;
|
|
19664
19718
|
}
|
|
19719
|
+
getLayer() {
|
|
19720
|
+
return this.layer;
|
|
19721
|
+
}
|
|
19665
19722
|
getItemOptions(item) {
|
|
19666
19723
|
const transparency = item.item_type === 'layer' && item.layer_transparency;
|
|
19667
19724
|
const opacity = typeof transparency === 'number' ? (100 - transparency) / 100 : undefined;
|
|
@@ -19682,12 +19739,7 @@ class NgwWebmapItem extends Item {
|
|
|
19682
19739
|
options.order = Number((this.options.order | 0) + '.' + subLevel);
|
|
19683
19740
|
}
|
|
19684
19741
|
if (item.item_type === 'layer') {
|
|
19685
|
-
const maxZoom = item
|
|
19686
|
-
? this._mapScaleToZoomLevel(item.layer_max_scale_denom)
|
|
19687
|
-
: this.webMap.options.maxZoom;
|
|
19688
|
-
const minZoom = item.layer_min_scale_denom
|
|
19689
|
-
? this._mapScaleToZoomLevel(item.layer_min_scale_denom)
|
|
19690
|
-
: this.webMap.options.minZoom;
|
|
19742
|
+
const { maxZoom, minZoom } = this._getZoomRange(item);
|
|
19691
19743
|
objectAssign(options, {
|
|
19692
19744
|
updateWmsParams: item.updateWmsParams,
|
|
19693
19745
|
url: item.url,
|
|
@@ -19710,6 +19762,23 @@ class NgwWebmapItem extends Item {
|
|
|
19710
19762
|
_mapScaleToZoomLevel(scale) {
|
|
19711
19763
|
return setScaleRatio(scale);
|
|
19712
19764
|
}
|
|
19765
|
+
_getZoomRange(item) {
|
|
19766
|
+
const minZoomMap = this.webMap.options.minZoom;
|
|
19767
|
+
const maxZoomMap = this.webMap.options.maxZoom;
|
|
19768
|
+
const minZoomWebmap = this.options.minZoom;
|
|
19769
|
+
const maxZoomWebmap = this.options.maxZoom;
|
|
19770
|
+
const minZoomLayer = item.layer_min_scale_denom
|
|
19771
|
+
? this._mapScaleToZoomLevel(item.layer_min_scale_denom)
|
|
19772
|
+
: undefined;
|
|
19773
|
+
const maxZoomLayer = item.layer_max_scale_denom
|
|
19774
|
+
? this._mapScaleToZoomLevel(item.layer_max_scale_denom)
|
|
19775
|
+
: undefined;
|
|
19776
|
+
const minZooms = [minZoomMap, minZoomWebmap, minZoomLayer].filter(Boolean);
|
|
19777
|
+
const maxZooms = [maxZoomMap, maxZoomWebmap, maxZoomLayer].filter(Boolean);
|
|
19778
|
+
const minZoom = Math.max(...minZooms);
|
|
19779
|
+
const maxZoom = Math.min(...maxZooms);
|
|
19780
|
+
return { minZoom, maxZoom };
|
|
19781
|
+
}
|
|
19713
19782
|
_init(item) {
|
|
19714
19783
|
this.initItem(item).then(() => {
|
|
19715
19784
|
this.emitter.emit('init');
|
|
@@ -19763,6 +19832,10 @@ NgwWebmapItem.options = {
|
|
|
19763
19832
|
}
|
|
19764
19833
|
},
|
|
19765
19834
|
},
|
|
19835
|
+
{
|
|
19836
|
+
name: 'opacity',
|
|
19837
|
+
handler: WebmapLayerOpacityPropertyHandler,
|
|
19838
|
+
},
|
|
19766
19839
|
],
|
|
19767
19840
|
};
|
|
19768
19841
|
|
|
@@ -19784,15 +19857,23 @@ async function createOnFirstShowAdapter({ webMap, adapterOptions = {}, onLayerAd
|
|
|
19784
19857
|
destroyed() {
|
|
19785
19858
|
return this._removed;
|
|
19786
19859
|
}
|
|
19787
|
-
showLayer() {
|
|
19860
|
+
async showLayer() {
|
|
19788
19861
|
this.options.visibility = true;
|
|
19789
19862
|
if (this.layer.length) {
|
|
19790
|
-
this.layer
|
|
19791
|
-
webMap.showLayer(x);
|
|
19792
|
-
}
|
|
19863
|
+
for (const x of this.layer) {
|
|
19864
|
+
await webMap.showLayer(x);
|
|
19865
|
+
}
|
|
19793
19866
|
}
|
|
19794
19867
|
else {
|
|
19795
|
-
this.loadLayer();
|
|
19868
|
+
await this.loadLayer();
|
|
19869
|
+
}
|
|
19870
|
+
}
|
|
19871
|
+
async hideLayer() {
|
|
19872
|
+
this.options.visibility = false;
|
|
19873
|
+
if (this.layer) {
|
|
19874
|
+
for (const x of this.layer) {
|
|
19875
|
+
await webMap.hideLayer(x);
|
|
19876
|
+
}
|
|
19796
19877
|
}
|
|
19797
19878
|
}
|
|
19798
19879
|
async loadLayer() {
|
|
@@ -19816,21 +19897,15 @@ async function createOnFirstShowAdapter({ webMap, adapterOptions = {}, onLayerAd
|
|
|
19816
19897
|
if (this._removed) {
|
|
19817
19898
|
webMap.removeLayer(adapter);
|
|
19818
19899
|
}
|
|
19900
|
+
this.layer.push(adapter);
|
|
19819
19901
|
if (this.options.visibility) {
|
|
19820
19902
|
await webMap.showLayer(adapter);
|
|
19821
19903
|
}
|
|
19822
|
-
this.layer.push(adapter);
|
|
19823
19904
|
this._creatingInProgress = false;
|
|
19824
19905
|
}
|
|
19825
19906
|
}
|
|
19826
19907
|
return this.layer;
|
|
19827
19908
|
}
|
|
19828
|
-
hideLayer() {
|
|
19829
|
-
this.options.visibility = false;
|
|
19830
|
-
if (this.layer) {
|
|
19831
|
-
this.layer.forEach((x) => webMap.hideLayer(x));
|
|
19832
|
-
}
|
|
19833
|
-
}
|
|
19834
19909
|
}
|
|
19835
19910
|
return OnFirstShowAdapter;
|
|
19836
19911
|
}
|
|
@@ -19949,14 +20024,19 @@ class NgwWebmapLayerAdapter {
|
|
|
19949
20024
|
delete this.response;
|
|
19950
20025
|
delete this._webmapLayersIds;
|
|
19951
20026
|
}
|
|
19952
|
-
showLayer() {
|
|
20027
|
+
async showLayer() {
|
|
20028
|
+
if (this.layer && this.layer.properties) {
|
|
20029
|
+
return this.layer.properties.property('visibility').set(true);
|
|
20030
|
+
}
|
|
20031
|
+
}
|
|
20032
|
+
async hideLayer() {
|
|
19953
20033
|
if (this.layer && this.layer.properties) {
|
|
19954
|
-
this.layer.properties.property('visibility').set(
|
|
20034
|
+
return this.layer.properties.property('visibility').set(false);
|
|
19955
20035
|
}
|
|
19956
20036
|
}
|
|
19957
|
-
|
|
20037
|
+
async setOpacity(val) {
|
|
19958
20038
|
if (this.layer && this.layer.properties) {
|
|
19959
|
-
this.layer.properties.property('
|
|
20039
|
+
return this.layer.properties.property('opacity').set(val);
|
|
19960
20040
|
}
|
|
19961
20041
|
}
|
|
19962
20042
|
/** @deprecated use {@link NgwWebmapLayerAdapter.getBounds} instead */
|
|
@@ -20048,6 +20128,8 @@ class NgwWebmapLayerAdapter {
|
|
|
20048
20128
|
options.order = this.options.order;
|
|
20049
20129
|
options.ratio = this.options.ratio;
|
|
20050
20130
|
options.crossOrigin = this.options.crossOrigin;
|
|
20131
|
+
options.minZoom = this.options.minZoom;
|
|
20132
|
+
options.maxZoom = this.options.maxZoom;
|
|
20051
20133
|
options.drawOrderEnabled = webmap.draw_order_enabled;
|
|
20052
20134
|
const layer = new this.NgwWebmapItem(this.options.webMap, webmap.root_item, options, this.options.connector);
|
|
20053
20135
|
layer.emitter.on('init', () => resolve(layer));
|
|
@@ -22010,7 +22092,9 @@ class GeoJsonAdapter extends BaseAdapter {
|
|
|
22010
22092
|
getBounds() {
|
|
22011
22093
|
if (this.layer) {
|
|
22012
22094
|
const bounds = this.layer.getBounds();
|
|
22013
|
-
|
|
22095
|
+
if (bounds.isValid()) {
|
|
22096
|
+
return boundsToArray(bounds);
|
|
22097
|
+
}
|
|
22014
22098
|
}
|
|
22015
22099
|
}
|
|
22016
22100
|
setOpacity(value) {
|
|
@@ -22072,8 +22156,9 @@ class GeoJsonAdapter extends BaseAdapter {
|
|
|
22072
22156
|
this._removePopup(popup);
|
|
22073
22157
|
}
|
|
22074
22158
|
};
|
|
22075
|
-
|
|
22076
|
-
|
|
22159
|
+
let content;
|
|
22160
|
+
if (options.createPopupContent) {
|
|
22161
|
+
content = await options.createPopupContent({
|
|
22077
22162
|
layer,
|
|
22078
22163
|
feature,
|
|
22079
22164
|
target: this,
|
|
@@ -22081,17 +22166,24 @@ class GeoJsonAdapter extends BaseAdapter {
|
|
|
22081
22166
|
close,
|
|
22082
22167
|
onClose,
|
|
22083
22168
|
...createFeaturePositionOptions(feature),
|
|
22084
|
-
})
|
|
22085
|
-
|
|
22169
|
+
});
|
|
22170
|
+
}
|
|
22171
|
+
else {
|
|
22172
|
+
content = options.popupContent;
|
|
22173
|
+
}
|
|
22086
22174
|
if (content && layer) {
|
|
22087
|
-
|
|
22175
|
+
const popupOptions = {
|
|
22088
22176
|
minWidth,
|
|
22089
22177
|
autoPan,
|
|
22090
|
-
maxWidth,
|
|
22178
|
+
// maxWidth,
|
|
22091
22179
|
closeButton,
|
|
22092
22180
|
closeOnClick: false,
|
|
22093
22181
|
autoClose: false,
|
|
22094
|
-
}
|
|
22182
|
+
};
|
|
22183
|
+
if (defined(maxWidth)) {
|
|
22184
|
+
popupOptions.maxWidth = maxWidth;
|
|
22185
|
+
}
|
|
22186
|
+
popup = layer.bindPopup(content, popupOptions);
|
|
22095
22187
|
const unselectOnClose = (_b = (_a = this.options.popupOptions) === null || _a === void 0 ? void 0 : _a.unselectOnClose) !== null && _b !== void 0 ? _b : true;
|
|
22096
22188
|
if (unselectOnClose) {
|
|
22097
22189
|
const p = layer.getPopup();
|
|
@@ -22101,9 +22193,7 @@ class GeoJsonAdapter extends BaseAdapter {
|
|
|
22101
22193
|
}, this);
|
|
22102
22194
|
}
|
|
22103
22195
|
this._openedPopup.push([popup, _closeHandlers, def]);
|
|
22104
|
-
|
|
22105
|
-
popup.openPopup(latlng);
|
|
22106
|
-
}, 0);
|
|
22196
|
+
popup.openPopup(latlng);
|
|
22107
22197
|
}
|
|
22108
22198
|
}
|
|
22109
22199
|
_removePopup(popup) {
|