@geogirafe/lib-geoportal 1.0.2248784880 → 1.0.2250838105

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
  }
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.2250838105",
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.2250838105", "build":"2250838105", "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
  }