@geogirafe/lib-geoportal 1.0.2248784880 → 1.0.2250843888

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.
@@ -36,7 +36,7 @@ export default class DrawingComponent extends GirafeHTMLElement implements IGira
36
36
  batchCreateMode: boolean;
37
37
  constructor(name?: string);
38
38
  render(): void;
39
- renderComponent(): void;
39
+ private renderComponent;
40
40
  refreshRender(): void;
41
41
  registerEvents(): void;
42
42
  unregisterEvents(): void;
@@ -82,9 +82,11 @@ input{border:1px solid var(--bkg-color-grad1);width:inherit;background-color:var
82
82
  super.render();
83
83
  if (this.isPanelVisible) {
84
84
  this.renderComponent();
85
+ this.state.layers.isSnappingActive = true;
85
86
  }
86
87
  else {
87
88
  this.hide();
89
+ this.state.layers.isSnappingActive = false;
88
90
  }
89
91
  super.girafeTranslate();
90
92
  }
@@ -56,9 +56,11 @@ export default class EditComponent extends GirafeHTMLElement {
56
56
  super.render();
57
57
  if (this.isPanelVisible) {
58
58
  this.renderComponent();
59
+ this.state.layers.isSnappingActive = true;
59
60
  }
60
61
  else {
61
62
  this.renderEmptyComponent();
63
+ this.state.layers.isSnappingActive = false;
62
64
  }
63
65
  super.girafeTranslate();
64
66
  }
@@ -17,6 +17,7 @@ declare class ExternalLayersComponent extends GirafeHTMLElement implements IGira
17
17
  loading: boolean;
18
18
  predefinedSources: PredefinedSource[];
19
19
  get predefinedWmsWmtsSources(): PredefinedSource[];
20
+ get hasPredefinedWmsWmtsSources(): boolean;
20
21
  selectedTab: 'wms_wmts' | 'file';
21
22
  private wmtsManager;
22
23
  private themeName?;
@@ -13,9 +13,9 @@ class ExternalLayersComponent extends GirafeHTMLElement {
13
13
  return uHtml `<style>
14
14
  *{font-family:Arial,sans-serif}.hidden{display:none!important}.gg-rotate90{transform:rotate(90deg)}.gg-rotate180{transform:rotate(180deg)}.gg-rotate270{transform:rotate(270deg)}img{filter:var(--svg-filter)}img.legend-image{filter:var(--svg-map-filter);background:var(--svg-legend-bkg)}div{scrollbar-width:thin}a,a:visited{color:var(--link-color)}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}@keyframes spin-wait{0%{transform:rotate(0)}7%{transform:rotate(360deg)}to{transform:rotate(360deg)}}.gg-spin{animation-name:spin;animation-duration:2s;animation-timing-function:linear;animation-iteration-count:infinite}.gg-spin-wait{animation-name:spin-wait;animation-duration:10s;animation-timing-function:linear;animation-iteration-count:infinite}::-webkit-scrollbar{width:5px}::-webkit-scrollbar-thumb{background:#999}.gg-button,.gg-select,.gg-input,.gg-textarea{background-color:var(--bkg-color);color:var(--text-color);border:var(--app-standard-border);box-sizing:border-box;cursor:pointer;border-radius:3px;outline:0;margin:0;padding:0 0 0 .5rem;display:inline-block}.gg-label{background-color:var(--bkg-color);color:var(--text-color);border:none;align-items:center;margin:0;padding:0;display:flex}.gg-button,.gg-select,.gg-input,.gg-label{min-height:calc(var(--app-standard-height)/1.5)}.gg-textarea{max-height:initial;resize:vertical;height:6rem;padding:.5rem;line-height:1.3rem}.gg-input{cursor:text}.gg-checkbox{accent-color:var(--text-color);width:1.2rem}.gg-range{accent-color:var(--text-color)}.gg-button{padding:0 .5rem}.gg-button.active{border:solid 1px var(--text-color-grad2);background-color:var(--text-color-grad2);color:var(--bkg-color)}.gg-button:disabled{color:gray;cursor:not-allowed;background-color:#d3d3d3;border:none}.gg-input:disabled,.gg-select:disabled,.gg-textarea:disabled{color:gray;cursor:not-allowed;background-color:#d3d3d3}.gg-button>img{vertical-align:middle}.gg-icon-button{color:var(--text-color);cursor:pointer;background-color:#0000;border:none;flex-direction:column;justify-content:center;align-items:center;padding:0;display:flex}.gg-icon{justify-content:center;align-items:center;display:flex}.gg-big,.gg-big-withtext{min-width:var(--app-standard-height);min-height:var(--app-standard-height);max-height:var(--app-standard-height)}.gg-big img,.gg-big-withtext img{width:calc(var(--app-standard-height) - 1.5rem);margin:0}.gg-big-withtext span{font-variant:small-caps;padding:0 1rem;font-size:.9rem}.gg-medium,.gg-medium-withtext{min-width:calc(var(--app-standard-height)/1.2);min-height:calc(var(--app-standard-height)/1.2);max-height:calc(var(--app-standard-height)/1.2);flex-direction:row}.gg-medium img{width:calc(var(--app-standard-height)/2.4);margin:0}.gg-medium-withtext img{width:calc(var(--app-standard-height)/2.4);margin-left:.5rem}.gg-medium-withtext span{padding:0 1rem 0 .5rem;font-size:.9rem}.gg-small,.gg-small-withtext{min-width:calc(var(--app-standard-height)/2);min-height:calc(var(--app-standard-height)/2);max-height:calc(var(--app-standard-height)/2);flex-direction:row}.gg-small img{width:calc(var(--app-standard-height)/3);margin:0}.gg-small-withtext img{width:calc(var(--app-standard-height)/3);margin-left:.5rem}.gg-small-withtext span{padding:0 .5rem 0 .3rem;font-size:.9rem}.gg-button:hover,.gg-select:hover,.gg-input:hover,.gg-textarea:hover,.gg-icon-button:hover{background-color:var(--bkg-color-grad1)}.gg-opacity{opacity:.5}.gg-opacity:hover{opacity:1;background-color:#0000}.gg-tabs{cursor:pointer;grid-auto-flow:column;padding-bottom:1rem;font-size:1rem;display:grid}.gg-tab{border:none;border-bottom:var(--app-standard-border);cursor:pointer;color:var(--text-color);background:0 0;padding:.5rem}.gg-tab.active{border-bottom:solid 1px var(--text-color)}.girafe-button-big,.girafe-button-large,.girafe-button-small,.girafe-button-tiny{color:var(--text-color);background-color:#0000;border:none;flex-direction:column;display:flex}.girafe-button-big:hover,.girafe-button-large:hover,.girafe-button-small:hover,.girafe-button-tiny:hover{background-color:var(--bkg-color-grad1);cursor:pointer}.girafe-button-big.dark,.girafe-button-large.dark,.girafe-button-small.dark,.girafe-button-tiny.dark{background-color:var(--bkg-color);filter:invert()}.girafe-button-big{width:var(--app-standard-height);height:var(--app-standard-height);align-items:center;padding:1rem}.girafe-button-big img{overflow:hidden}.girafe-button-large{flex-direction:row}.girafe-button-large img{height:2rem;margin:.3rem}.girafe-button-large span{height:2rem;margin:.3rem;line-height:2rem}.girafe-button-small{min-width:calc(var(--app-standard-height)/2);height:calc(var(--app-standard-height)/2);align-items:center;padding:.5rem}.girafe-button-small img{overflow:hidden}.girafe-button-small span{text-align:left;text-overflow:ellipsis;width:100%;overflow:hidden}.girafe-button-tiny{align-items:center;width:1rem;height:1rem;padding:0}.girafe-button-tiny img{overflow:hidden}
15
15
  </style><style>
16
- #panel{background:var(--bkg-color);height:100%;color:var(--text-color);flex-direction:column;padding:0 1rem;display:flex}#content{flex-direction:column;flex-grow:1;margin:0;display:flex}header{background:#fff;margin:0;position:sticky;top:-5px}h4{margin-bottom:.5rem}ul{margin-top:0;margin-left:0;padding-left:2rem;line-height:1.3rem;list-style-type:disc}.clearable-input{background-color:var(--bkg-color);border:1px solid #cfd6dd;border-radius:4px;flex-direction:row;margin-bottom:.1rem;display:flex}.scan-button{float:right}.layers{border-top:1px solid #ccc;flex-direction:column;flex-grow:1;margin-top:1rem;padding-top:.5rem;display:flex;overflow:hidden}ul.results{border:none;margin-bottom:.5rem;padding:0;list-style:none;overflow-y:auto}.result{height:1.6rem;display:flex}.result>button>span{text-align:left;white-space:nowrap;text-overflow:ellipsis;overflow:hidden}#panel>div{padding:1rem}#layers li{margin-top:.3rem;margin-bottom:.3rem}#layers li button{text-align:left;overflow-wrap:anywhere;text-wrap-style:balance}#file-selector{display:grid}#file,#file-label{grid-area:1/1}#file{opacity:0;z-index:2;cursor:pointer}#file::file-selector-button{cursor:pointer}#loading-icon{flex-grow:1;align-self:center;width:3rem}.title{margin-top:0}.filter-buttons{flex-direction:row;margin:2px;display:flex}.filter-buttons span{flex-grow:1;align-self:center}.clearable-input-field{width:90%;color:var(--text-color);background:0 0;border:0;outline:none;flex:auto;padding:0;font-size:1rem}.filter-icon,.delete-icon{width:16px;color:var(--text-color);padding:0 .5rem}.delete-button{cursor:pointer;background-color:#0000;border:none;padding:0}
16
+ #panel{background:var(--bkg-color);height:100%;color:var(--text-color);flex-direction:column;padding:0 1rem;display:flex}#content{flex-direction:column;flex-grow:1;margin:0;display:flex}header{background-color:var(--bkg-color);margin:0;position:sticky;top:-5px}h4{margin-bottom:.5rem}ul{margin-top:0;margin-left:0;padding-left:2rem;line-height:1.3rem;list-style-type:disc}.clearable-input{background-color:var(--bkg-color);border:1px solid #cfd6dd;border-radius:4px;flex-direction:row;margin-bottom:.1rem;display:flex}.scan-button{float:right}.layers{border-top:1px solid #ccc;flex-direction:column;flex-grow:1;margin-top:1rem;padding-top:.5rem;display:flex;overflow:hidden}ul.results{border:none;margin-bottom:.5rem;padding:0;list-style:none;overflow-y:auto}.result{height:1.6rem;display:flex}.result>button>span{text-align:left;white-space:nowrap;text-overflow:ellipsis;overflow:hidden}#panel>div{padding:1rem}#layers li{margin-top:.3rem;margin-bottom:.3rem}#layers li button{text-align:left;overflow-wrap:anywhere;text-wrap-style:balance}#file-selector{display:grid}#file,#file-label{grid-area:1/1}#file{opacity:0;z-index:2;cursor:pointer}#file::file-selector-button{cursor:pointer}#loading-icon{flex-grow:1;align-self:center;width:3rem}.title{margin-top:0}.filter-buttons{flex-direction:row;margin:2px;display:flex}.filter-buttons span{flex-grow:1;align-self:center}.clearable-input-field{width:90%;color:var(--text-color);background:0 0;border:0;outline:none;flex:auto;padding:0;font-size:1rem}.filter-icon,.delete-icon{width:16px;color:var(--text-color);padding:0 .5rem}.delete-button{cursor:pointer;background-color:#0000;border:none;padding:0}
17
17
  </style>
18
- <div id="panel"><header class="gg-tabs"><button class="${this.selectedTab === 'wms_wmts' ? 'gg-tab active' : 'gg-tab'}" onclick="${() => this.setSelectedTab('wms_wmts')}" i18n="wms_wmts"></button> <button class="${this.selectedTab === 'file' ? 'gg-tab active' : 'gg-tab'}" onclick="${() => this.setSelectedTab('file')}" i18n="local file"></button></header><section class="${(this.selectedTab === 'wms_wmts') ? 'group' : 'hidden'}"><h4 class="title" i18n="Suggestions">Suggestions</h4><ul class="suggestions">${this.predefinedWmsWmtsSources.map(source => uHtmlFor(source, source.label) `<li><a href="javascript:void(0)" onclick="${() => this.scanSource(source.url, source.type)}">${source.label}</a></li>`)}</ul><h4 class="title" i18n="Custom service URL">Custom service URL</h4><div class="clearable-input"><input id="url" class="gg-input clearable-input-field" oninput="${() => this.typeUrl()}"><br><button id="clear-url" class="delete-button hidden" onclick="${() => this.clearUrl()}"><img class="delete-icon" alt="delete-button-icon" tip="Reset filter" i18n="Reset filter" src="icons/trash.svg"></button></div><button i18n="Scan Source" class="gg-button scan-button" onclick="${() => this.scanSource()}">Scan Source</button></section><section class="${(this.selectedTab === 'file') ? 'group' : 'hidden'}"><h4 class="title" i18n="Choose local file">Choose local file</h4><div id="file-selector"><label for="file" id="file-label"><button class="gg-button" i18n="Select File"></button> <span>${this.fileDescription}</span></label> <input type="file" accept=".gpx,.kml,.geojson,.json" id="file" onchange="${() => this.render()}"><br></div><button id="load" i18n="Load File" class="gg-button" onclick="${() => this.loadFile()}"></button></section><section class="${(this.selectedTab === 'wms_wmts' && this.externalLayers.length > 0) || this.loading ? 'layers' : 'hidden'}"><h4 class="title" i18n="Layers (from Capabilities)">Layers (from Capabilities)</h4><div class="clearable-input"><img class="filter-icon" alt="filter-button-icon" src="icons/filter.svg"> <input id="layer-search-field" class="gg-input clearable-input-field" placeholder="${this.context.i18nManager.getTranslation('Filter external layers...')}" i18n="Filter external layers..." autocomplete="off" autocorrect="off" oninput="${(e) => this.filterLayers(e.target.value)}"> <button class="${this.isFiltered ? 'delete-button' : 'hidden'}" onclick="${() => this.clearFilter()}"><img class="delete-icon" alt="delete-button-icon" tip="Reset filter" i18n="Reset filter" src="icons/trash.svg"></button></div><div class="filter-buttons"><span>${Object.values(this.externalLayers).filter(layer => layer.isSelected).length.toString()} ${this.context.i18nManager.getTranslation('layers selected')} </span><button class="gg-button" tip="Select all filtered layers" onclick="${() => this.selectVisible()}">+</button> <button class="gg-button" tip="Unselect all filtered layers" onclick="${() => this.deselectVisible()}">-</button> <button class="gg-button" tip="Select none" onclick="${() => this.deselectAll()}">--</button></div><img id="loading-icon" alt="loading-icon" src="icons/loading.svg" class="${this.loading ? 'gg-spin' : 'hidden'}"><ul class="results">${this.filteredLayers.map(layer => uHtmlFor(layer, layer.treeItemId) `<li class="result"><button class="${layer.isSelected ? 'gg-icon-button gg-small gg-selected' : 'gg-icon-button gg-small gg-opacity'}" tip="Activate / Deactivate" onclick="${() => this.selectLayer(layer)}"><img class="${layer.isSelected ? 'gg-checkbox' : 'hidden'}" alt="Expand/Collapse button" src="icons/checked-full.svg"> <img class="${!layer.isSelected ? 'gg-checkbox' : 'hidden'}" alt="Expand/Collapse button" src="icons/checked-no.svg"></button> <button class="${layer.isSelected ? 'gg-icon-button gg-small gg-selected' : 'gg-icon-button gg-small gg-opacity'}" onclick="${() => this.selectLayer(layer)}"><span i18n="${layer.name}" class="gg-tree-label">${layer.name}</span></button></li>`)}</ul><button id="add" tip="Add selected" i18n="Add selected" class="gg-button" onclick="${() => this.addSelectedLayers()}">Add selected</button></section></div>`;
18
+ <div id="panel"><header class="gg-tabs"><button class="${this.selectedTab === 'wms_wmts' ? 'gg-tab active' : 'gg-tab'}" onclick="${() => this.setSelectedTab('wms_wmts')}" i18n="wms_wmts"></button> <button class="${this.selectedTab === 'file' ? 'gg-tab active' : 'gg-tab'}" onclick="${() => this.setSelectedTab('file')}" i18n="local file"></button></header><section class="${(this.selectedTab === 'wms_wmts') ? 'group' : 'hidden'}"><h4 class="title" i18n="Suggestions" ?hidden="${this.hasPredefinedWmsWmtsSources}">Suggestions</h4><ul class="suggestions" ?hidden="${this.hasPredefinedWmsWmtsSources}">${this.predefinedWmsWmtsSources.map(source => uHtmlFor(source, source.label) `<li><a href="javascript:void(0)" onclick="${() => this.scanSource(source.url, source.type)}">${source.label}</a></li>`)}</ul><h4 class="title" i18n="Custom service URL">Custom service URL</h4><div class="clearable-input"><input id="url" class="gg-input clearable-input-field" oninput="${() => this.typeUrl()}"><br><button id="clear-url" class="delete-button hidden" onclick="${() => this.clearUrl()}"><img class="delete-icon" alt="delete-button-icon" tip="Reset filter" i18n="Reset filter" src="icons/trash.svg"></button></div><button i18n="Scan Source" class="gg-button scan-button" onclick="${() => this.scanSource()}">Scan Source</button></section><section class="${(this.selectedTab === 'file') ? 'group' : 'hidden'}"><h4 class="title" i18n="Choose local file">Choose local file</h4><div id="file-selector"><label for="file" id="file-label"><button class="gg-button" i18n="Select File"></button> <span>${this.fileDescription}</span></label> <input type="file" accept=".gpx,.kml,.geojson,.json" id="file" onchange="${() => this.render()}"><br></div><button id="load" i18n="Load File" class="gg-button" onclick="${() => this.loadFile()}"></button></section><section class="${(this.selectedTab === 'wms_wmts' && this.externalLayers.length > 0) || this.loading ? 'layers' : 'hidden'}"><h4 class="title" i18n="Layers (from Capabilities)">Layers (from Capabilities)</h4><div class="clearable-input"><img class="filter-icon" alt="filter-button-icon" src="icons/filter.svg"> <input id="layer-search-field" class="gg-input clearable-input-field" placeholder="${this.context.i18nManager.getTranslation('Filter external layers...')}" i18n="Filter external layers..." autocomplete="off" autocorrect="off" oninput="${(e) => this.filterLayers(e.target.value)}"> <button class="${this.isFiltered ? 'delete-button' : 'hidden'}" onclick="${() => this.clearFilter()}"><img class="delete-icon" alt="delete-button-icon" tip="Reset filter" i18n="Reset filter" src="icons/trash.svg"></button></div><div class="filter-buttons"><span>${Object.values(this.externalLayers).filter(layer => layer.isSelected).length.toString()} ${this.context.i18nManager.getTranslation('layers selected')} </span><button class="gg-button" tip="Select all filtered layers" onclick="${() => this.selectVisible()}">+</button> <button class="gg-button" tip="Unselect all filtered layers" onclick="${() => this.deselectVisible()}">-</button> <button class="gg-button" tip="Select none" onclick="${() => this.deselectAll()}">--</button></div><img id="loading-icon" alt="loading-icon" src="icons/loading.svg" class="${this.loading ? 'gg-spin' : 'hidden'}"><ul class="results">${this.filteredLayers.map(layer => uHtmlFor(layer, layer.treeItemId) `<li class="result"><button class="${layer.isSelected ? 'gg-icon-button gg-small gg-selected' : 'gg-icon-button gg-small gg-opacity'}" tip="Activate / Deactivate" onclick="${() => this.selectLayer(layer)}"><img class="${layer.isSelected ? 'gg-checkbox' : 'hidden'}" alt="Expand/Collapse button" src="icons/checked-full.svg"> <img class="${!layer.isSelected ? 'gg-checkbox' : 'hidden'}" alt="Expand/Collapse button" src="icons/checked-no.svg"></button> <button class="${layer.isSelected ? 'gg-icon-button gg-small gg-selected' : 'gg-icon-button gg-small gg-opacity'}" onclick="${() => this.selectLayer(layer)}"><span i18n="${layer.name}" class="gg-tree-label">${layer.name}</span></button></li>`)}</ul><button id="add" tip="Add selected" i18n="Add selected" class="gg-button" onclick="${() => this.addSelectedLayers()}">Add selected</button></section></div>`;
19
19
  };
20
20
  isPanelVisible = false;
21
21
  panelTitle = 'ext-layer-panel';
@@ -25,6 +25,9 @@ class ExternalLayersComponent extends GirafeHTMLElement {
25
25
  get predefinedWmsWmtsSources() {
26
26
  return this.predefinedSources.filter((source) => source.type === 'WMS' || source.type === 'WMTS');
27
27
  }
28
+ get hasPredefinedWmsWmtsSources() {
29
+ return this.predefinedWmsWmtsSources.length == 0;
30
+ }
28
31
  selectedTab = 'wms_wmts';
29
32
  wmtsManager;
30
33
  themeName;
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "name": "GeoGirafe PSC",
6
6
  "url": "https://doc.geomapfish.dev"
7
7
  },
8
- "version": "1.0.2248784880",
8
+ "version": "1.0.2250843888",
9
9
  "type": "module",
10
10
  "engines": {
11
11
  "node": ">=20.19.0"
@@ -1 +1 @@
1
- {"version":"1.0.2248784880", "build":"2248784880", "date":"07/01/2026"}
1
+ {"version":"1.0.2250843888", "build":"2250843888", "date":"08/01/2026"}
@@ -1,9 +1,13 @@
1
1
  import GirafeSingleton from '../../base/GirafeSingleton.js';
2
2
  declare class SnapManager extends GirafeSingleton {
3
- private readonly snapLayers;
3
+ private readonly activeSnapLayers;
4
+ private inactiveSnapLayers;
4
5
  private get olMap();
6
+ private get state();
5
7
  initializeSingleton(): void;
6
8
  private mapInteractionsChanged;
9
+ private activateSnappingForAllLayers;
10
+ private deactivateSnappingForAllLayers;
7
11
  private layerUpdated;
8
12
  private createSnapOptions;
9
13
  private registerLayer;
@@ -4,10 +4,14 @@ import SelectionParam from '../../models/selectionparam.js';
4
4
  import Snap from 'ol/interaction/Snap.js';
5
5
  import { Collection } from 'ol';
6
6
  class SnapManager extends GirafeSingleton {
7
- snapLayers = new Map();
7
+ activeSnapLayers = new Map();
8
+ inactiveSnapLayers = [];
8
9
  get olMap() {
9
10
  return this.context.mapManager.getMap();
10
11
  }
12
+ get state() {
13
+ return this.context.stateManager.state;
14
+ }
11
15
  initializeSingleton() {
12
16
  this.context.stateManager.subscribe(/layers\.layersList\..*\.activeState/, (_oldActive, _newActive, layer) => {
13
17
  this.layerUpdated(layer);
@@ -15,19 +19,41 @@ class SnapManager extends GirafeSingleton {
15
19
  this.context.stateManager.subscribe(/layers\.layersList\..*\.snapActive/, (_oldSnap, _newSnap, layer) => {
16
20
  this.layerUpdated(layer);
17
21
  });
22
+ this.context.stateManager.subscribe('layers.isSnappingActive', (_, isSnappingActive) => {
23
+ if (isSnappingActive) {
24
+ this.activateSnappingForAllLayers();
25
+ }
26
+ else {
27
+ this.deactivateSnappingForAllLayers();
28
+ }
29
+ });
18
30
  this.olMap
19
31
  .getInteractions()
20
32
  .on('add', (event) => this.mapInteractionsChanged(event.element));
21
33
  }
22
34
  mapInteractionsChanged(interaction) {
23
35
  if (!(interaction instanceof Snap)) {
24
- this.snapLayers.forEach((options) => {
36
+ for (const options of this.activeSnapLayers.values()) {
25
37
  // Snapping interactions have to be removed and readded, because they mut be the last ones in the list of interactions
26
38
  // This is a limitation of OpenLayers. Otherwise the drawing interaction will prevail to the snapping one
27
39
  // And snapping won't work when the drawing tool is changed.
28
40
  this.olMap.removeInteraction(options.snapInteraction);
29
41
  this.olMap.addInteraction(options.snapInteraction);
30
- });
42
+ }
43
+ }
44
+ }
45
+ activateSnappingForAllLayers() {
46
+ for (const layer of this.inactiveSnapLayers) {
47
+ const snapOptions = this.createSnapOptions(layer);
48
+ this.registerLayer(layer, snapOptions);
49
+ }
50
+ this.inactiveSnapLayers = [];
51
+ }
52
+ deactivateSnappingForAllLayers() {
53
+ const layersToDeactivate = Array.from(this.activeSnapLayers.keys());
54
+ for (const layer of layersToDeactivate) {
55
+ this.unregisterLayer(layer);
56
+ this.inactiveSnapLayers.push(layer);
31
57
  }
32
58
  }
33
59
  layerUpdated(layer) {
@@ -36,8 +62,13 @@ class SnapManager extends GirafeSingleton {
36
62
  return;
37
63
  }
38
64
  if (layer.active && layer.snapActive) {
39
- const snapOptions = this.createSnapOptions(layer);
40
- this.registerLayer(layer, snapOptions);
65
+ if (this.state.layers.isSnappingActive) {
66
+ const snapOptions = this.createSnapOptions(layer);
67
+ this.registerLayer(layer, snapOptions);
68
+ }
69
+ else {
70
+ this.inactiveSnapLayers.push(layer);
71
+ }
41
72
  }
42
73
  else {
43
74
  this.unregisterLayer(layer);
@@ -60,7 +91,7 @@ class SnapManager extends GirafeSingleton {
60
91
  return snapOptions;
61
92
  }
62
93
  registerLayer(layer, snapOptions) {
63
- this.snapLayers.set(layer, snapOptions);
94
+ this.activeSnapLayers.set(layer, snapOptions);
64
95
  this.loadFeaturesForLayer(layer, snapOptions);
65
96
  snapOptions.snapInteraction.setActive(true);
66
97
  this.olMap.addInteraction(snapOptions.snapInteraction);
@@ -68,23 +99,23 @@ class SnapManager extends GirafeSingleton {
68
99
  this.olMap.getView().on('change', this.reloadFeatures.bind(this));
69
100
  }
70
101
  unregisterLayer(layer) {
71
- const snapOptions = this.snapLayers.get(layer);
102
+ const snapOptions = this.activeSnapLayers.get(layer);
72
103
  if (snapOptions) {
73
104
  snapOptions.snapInteraction.setActive(false);
74
105
  snapOptions.snapFeatures.clear();
75
106
  this.olMap.removeInteraction(snapOptions.snapInteraction);
76
- this.snapLayers.delete(layer);
107
+ this.activeSnapLayers.delete(layer);
77
108
  }
78
109
  }
79
110
  reloadFeatures() {
80
- for (const [layer, options] of this.snapLayers) {
111
+ for (const [layer, options] of this.activeSnapLayers) {
81
112
  this.loadFeaturesForLayer(layer, options);
82
113
  }
83
114
  }
84
115
  async loadFeaturesForLayer(layer, options) {
85
116
  const client = this.context.wfsManager.getClient(layer.ogcServer);
86
117
  const extent = this.olMap.getView().getViewStateAndExtent().extent;
87
- const selectionParam = new SelectionParam(layer.ogcServer, [layer], this.context.stateManager.state.projection, extent);
118
+ const selectionParam = new SelectionParam(layer.ogcServer, [layer], this.state.projection, extent);
88
119
  const features = await client.getFeature(selectionParam);
89
120
  options.snapFeatures.extend(features);
90
121
  }
@@ -1,4 +1,5 @@
1
1
  import BaseLayer from '../../models/layers/baselayer.js';
2
2
  export default class LayersConfig {
3
3
  layersList: BaseLayer[];
4
+ isSnappingActive: boolean;
4
5
  }
@@ -1,3 +1,4 @@
1
1
  export default class LayersConfig {
2
2
  layersList = [];
3
+ isSnappingActive = false;
3
4
  }