maplibre-gl-geo-editor 0.10.4 → 0.11.1

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 CHANGED
@@ -60,9 +60,154 @@ A powerful MapLibre GL plugin for creating and editing geometries. Extends the f
60
60
  ## Installation
61
61
 
62
62
  ```bash
63
- npm install maplibre-gl-geo-editor @geoman-io/maplibre-geoman-free maplibre-gl
63
+ npm install maplibre-gl-geo-editor @geoman-io/maplibre-geoman-free@^0.9.1 maplibre-gl@^6
64
64
  ```
65
65
 
66
+ Requires Geoman Free 0.9.1 (0.9.x) and MapLibre GL JS 6.x. Both dependencies
67
+ use ESM; MapLibre 6 requires named or namespace imports rather than a default import.
68
+
69
+ With Vite, configure the worker before creating any maps:
70
+
71
+ ```typescript
72
+ import { setWorkerUrl } from 'maplibre-gl';
73
+ import workerUrl from 'maplibre-gl/dist/maplibre-gl-worker.mjs?worker&url';
74
+ setWorkerUrl(workerUrl);
75
+ ```
76
+
77
+ The `?worker&url` query bundles the worker's dependencies for production too.
78
+ Other bundlers require their own worker setup; see the
79
+ [MapLibre installation guide](https://maplibre.org/maplibre-gl-js/docs/#installation).
80
+
81
+
82
+ ## Snap target events
83
+
84
+ Enable local snap observation to identify the feature and vertex or segment
85
+ selected by Geoman. No Geoman fork or upstream patch is required.
86
+
87
+ ```typescript
88
+ const editor = new GeoEditor({
89
+ snapEventsEnabled: true,
90
+ onSnap: ({ coordinate, target }) => {
91
+ if (target.kind === 'custom') return; // No feature identity for custom coordinates
92
+ console.log(target.featureId, target.feature.properties, coordinate);
93
+ if (target.kind === 'vertex') {
94
+ console.log(target.coordinatePath); // e.g. ['geometry', 'coordinates', 2]
95
+ } else {
96
+ console.log(target.segmentPaths); // Paths to both segment endpoints
97
+ }
98
+ },
99
+ onUnsnap: () => console.log('Snap target cleared'),
100
+ });
101
+ ```
102
+
103
+ The same payloads are emitted as `CustomEvent.detail` on `map.getContainer()`
104
+ under `gm:snap` and `gm:unsnap`, following this editor's existing event convention.
105
+ These are not MapLibre `map.on()` events. `onSnap` fires for each resolved snap
106
+ calculation; `onUnsnap` fires when the target changes or is cleared.
107
+ `editor.getSnapTarget()` returns a copy of the latest preview or `null`.
108
+ `editor.isSnapTrackingAvailable()` reports whether an active compatible snapping
109
+ helper is being observed; it is false while the helper is disabled or unavailable.
110
+
111
+ Targets contain a snapshot of the target GeoJSON and its properties. `featureId`
112
+ is Geoman's ID, not automatically an OSM ID; use your application's identity
113
+ mapping. Paths address the snapshot Feature, including polygon ring and multipart
114
+ indices. Coincident features follow Geoman's actual selection order. Custom snaps
115
+ have no feature metadata, and temporary feature targets are marked `temporary`.
116
+
117
+ **These are preview events, not vertex-commit events.** Applications must associate
118
+ previews with their draw/edit transactions and verify the committed vertex before
119
+ changing node references. This feature does not merge nodes, preserve an OSM graph,
120
+ or generate changesets. Keep NWR IDs, versions, and relations in application state.
121
+
122
+ The observer wraps methods on the active helper instance and restores them when
123
+ Geoman is replaced or the editor is removed. Its internal integration and segment
124
+ selection assumptions are tested against Geoman Free 0.9.1. Run the snap tests
125
+ when upgrading Geoman; unsupported helper shapes leave tracking unavailable.
126
+
127
+ ### Getting the identity of a snapped node
128
+
129
+ Use the selected feature **and its vertex path** to look up the node identity.
130
+ `target.featureId` identifies the Geoman feature (for example, a way), while
131
+ `target.coordinatePath` identifies the vertex within that feature. Equal
132
+ coordinates alone do not establish that two vertices are the same OSM node.
133
+
134
+ Store the original node IDs and versions alongside your geometry when loading
135
+ data. For example, a three-vertex LineString can carry these application-defined
136
+ properties, ordered exactly like its `geometry.coordinates`:
137
+
138
+ ```typescript
139
+ const properties = {
140
+ osm_id: 'way/201',
141
+ osm_version: 7,
142
+ node_ids: ['node/101', 'node/102', 'node/103'],
143
+ node_versions: [2, 5, 1],
144
+ };
145
+ ```
146
+
147
+ Then resolve vertex snaps in the editor callback:
148
+
149
+ ```typescript
150
+ import { GeoEditor } from 'maplibre-gl-geo-editor';
151
+
152
+ const editor = new GeoEditor({
153
+ snapEventsEnabled: true,
154
+ onSnap: ({ target }) => {
155
+ if (target.kind !== 'vertex') return;
156
+ const feature = target.feature;
157
+ if (feature.geometry.type !== 'LineString') return;
158
+
159
+ // LineString path: ['geometry', 'coordinates', vertexIndex]
160
+ const vertexIndex = target.coordinatePath[2];
161
+ const { node_ids, node_versions } = feature.properties ?? {};
162
+ if (typeof vertexIndex !== 'number' || !Array.isArray(node_ids)) return;
163
+ if (node_ids.length !== feature.geometry.coordinates.length) return;
164
+
165
+ console.log({
166
+ featureId: target.featureId,
167
+ nodeId: node_ids[vertexIndex],
168
+ nodeVersion: Array.isArray(node_versions) && node_versions.length === node_ids.length
169
+ ? node_versions[vertexIndex]
170
+ : undefined,
171
+ });
172
+ },
173
+ });
174
+
175
+ // Connect to your existing Geoman instance and map.
176
+ editor.setGeoman(geoman);
177
+ map.addControl(editor, 'top-left');
178
+ ```
179
+
180
+ The `node_ids` and `node_versions` fields above are your application's metadata;
181
+ Geoman does not fetch or populate them. A way's version is separate from each
182
+ referenced node's version. You can instead keep this information in an external
183
+ store keyed by the editor feature ID and vertex path.
184
+
185
+ For other geometries, include every part and ring index when resolving a path:
186
+
187
+ | Target geometry | Vertex path | Suggested node-ID lookup |
188
+ | --- | --- | --- |
189
+ | LineString | `['geometry', 'coordinates', vertex]` | `node_ids[vertex]` |
190
+ | MultiLineString | `['geometry', 'coordinates', part, vertex]` | `node_ids[part][vertex]` |
191
+ | Polygon | `['geometry', 'coordinates', ring, vertex]` | `node_ids[ring][vertex]` |
192
+ | MultiPolygon | `['geometry', 'coordinates', polygon, ring, vertex]` | `node_ids[polygon][ring][vertex]` |
193
+
194
+ For polygons, ring `0` is the exterior and later rings are holes. Mirror that
195
+ structure in your metadata; the closing coordinate must reference the same node
196
+ ID as the first coordinate. For a segment snap, resolve both paths in
197
+ `target.segmentPaths` to identify its endpoint nodes. A snap to the segment's
198
+ interior does not identify an existing node at the snapped position.
199
+
200
+ Keep these mappings synchronized with edits: moving a vertex retains its ID,
201
+ inserting a vertex adds a new local ID, and deleting a vertex removes its
202
+ reference. Do not simply renumber existing nodes after an insertion. Connecting
203
+ or merging nodes requires an explicit application-level topology operation when
204
+ the edit is committed, rather than updating references on every snap preview.
205
+
206
+ Try the [Snap Target Inspector](examples/snapping/index.html) on the examples
207
+ page. It displays node IDs, way versions, segment
208
+ endpoints, and the event payload. Its LineString demo preserves existing IDs
209
+ during vertex edits and assigns inserted vertices IDs such as `local/node-1`.
210
+
66
211
  ## Usage
67
212
 
68
213
  ### Basic Usage (Vanilla JS/TS)
@@ -72,7 +217,7 @@ import 'maplibre-gl/dist/maplibre-gl.css';
72
217
  import '@geoman-io/maplibre-geoman-free/dist/maplibre-geoman.css';
73
218
  import 'maplibre-gl-geo-editor/style.css';
74
219
 
75
- import maplibregl from 'maplibre-gl';
220
+ import * as maplibregl from 'maplibre-gl';
76
221
  import { Geoman } from '@geoman-io/maplibre-geoman-free';
77
222
  import { GeoEditor } from 'maplibre-gl-geo-editor';
78
223
 
@@ -208,7 +353,7 @@ const schema = geoEditor.getAttributeSchema();
208
353
 
209
354
  ```tsx
210
355
  import { useEffect, useRef, useState } from 'react';
211
- import maplibregl from 'maplibre-gl';
356
+ import * as maplibregl from 'maplibre-gl';
212
357
  import { Geoman } from '@geoman-io/maplibre-geoman-free';
213
358
  import { GeoEditorReact } from 'maplibre-gl-geo-editor/react';
214
359
 
@@ -293,6 +438,7 @@ function App() {
293
438
  | `attributePanelSideOffset` | `number` | `10` | Offset from left/right side of map container in pixels |
294
439
  | `attributePanelTitle` | `string` | `'Feature Properties'` | Title of the attribute panel |
295
440
  | `onAttributeChange` | `(event) => void` | - | Callback when feature attributes change |
441
+ | `createPopup` | `(options) => GeoEditorPopup` | MapLibre `Popup` | Builds the rotate and feature-properties popups; pass another engine's popup class (for example mapbox-gl's) when the editor runs on a non-MapLibre map |
296
442
  | `enableHistory` | `boolean` | `true` | Enable undo/redo functionality |
297
443
  | `maxHistorySize` | `number` | `50` | Maximum number of history entries |
298
444
  | `onHistoryChange` | `(canUndo, canRedo) => void` | - | Callback when history state changes |
@@ -16080,6 +16080,157 @@ function unkinkPolygon(geojson) {
16080
16080
  });
16081
16081
  return featureCollection(features);
16082
16082
  }
16083
+ function visitGeometry(geometry, vertex, segment, path = ["geometry"]) {
16084
+ if (geometry.type === "GeometryCollection") {
16085
+ geometry.geometries.forEach(
16086
+ (part, index) => visitGeometry(part, vertex, segment, [...path, "geometries", index])
16087
+ );
16088
+ return;
16089
+ }
16090
+ const isPosition = (value) => Array.isArray(value) && typeof value[0] === "number";
16091
+ function walk(value, currentPath) {
16092
+ if (isPosition(value)) {
16093
+ vertex({ coordinate: [value[0], value[1]], path: currentPath });
16094
+ } else if (Array.isArray(value)) {
16095
+ value.forEach((item, index) => {
16096
+ walk(item, [...currentPath, index]);
16097
+ const next = value[index + 1];
16098
+ if (geometry.type !== "MultiPoint" && isPosition(item) && isPosition(next)) {
16099
+ segment(
16100
+ { coordinate: [item[0], item[1]], path: [...currentPath, index] },
16101
+ {
16102
+ coordinate: [next[0], next[1]],
16103
+ path: [...currentPath, index + 1]
16104
+ }
16105
+ );
16106
+ }
16107
+ });
16108
+ }
16109
+ }
16110
+ walk(geometry.coordinates, [...path, "coordinates"]);
16111
+ }
16112
+ function observeSnapping(value, notify) {
16113
+ const helper = value;
16114
+ if (!helper || typeof helper.getSnappedLngLat !== "function" || typeof helper.getPointsSnapping !== "function" || typeof helper.getCustomLngLatsSnapping !== "function" || !helper.shapeSnappingHandlers || typeof helper.gm?.mapAdapter?.project !== "function")
16115
+ return null;
16116
+ let captures = null;
16117
+ const restorers = [];
16118
+ function wrap(object, key, replacement) {
16119
+ const original2 = object[key];
16120
+ const own = Object.prototype.hasOwnProperty.call(object, key);
16121
+ object[key] = replacement;
16122
+ restorers.push(() => {
16123
+ if (object[key] !== replacement) return;
16124
+ if (own) object[key] = original2;
16125
+ else delete object[key];
16126
+ });
16127
+ }
16128
+ function capture(handler, kind) {
16129
+ return function(feature2, lngLat, point2) {
16130
+ const result = handler.call(helper, feature2, lngLat, point2);
16131
+ captures?.push({ result, feature: feature2, kind });
16132
+ return result;
16133
+ };
16134
+ }
16135
+ wrap(
16136
+ helper,
16137
+ "getPointsSnapping",
16138
+ capture(helper.getPointsSnapping, "vertex")
16139
+ );
16140
+ for (const [shape, handler] of Object.entries(helper.shapeSnappingHandlers)) {
16141
+ if (handler)
16142
+ wrap(helper.shapeSnappingHandlers, shape, capture(handler, "segment"));
16143
+ }
16144
+ const custom = helper.getCustomLngLatsSnapping;
16145
+ wrap(helper, "getCustomLngLatsSnapping", function(point2) {
16146
+ const lngLat = custom.call(helper, point2);
16147
+ if (lngLat)
16148
+ captures?.push({ result: { lngLat, distance: 0 }, kind: "custom" });
16149
+ return lngLat;
16150
+ });
16151
+ const original = helper.getSnappedLngLat;
16152
+ wrap(helper, "getSnappedLngLat", function(lngLat, point2) {
16153
+ const previous = captures;
16154
+ const observed = [];
16155
+ captures = observed;
16156
+ let coordinate;
16157
+ try {
16158
+ coordinate = original.call(helper, lngLat, point2);
16159
+ } finally {
16160
+ captures = previous;
16161
+ }
16162
+ const winner = observed.find(
16163
+ ({ result, kind }) => result.lngLat === coordinate && (kind === "custom" || result.distance < helper.tolerance)
16164
+ );
16165
+ const target = winner ? describeTarget(helper, winner, lngLat) : null;
16166
+ notify(
16167
+ target ? {
16168
+ coordinate: [...coordinate],
16169
+ pointerCoordinate: [...lngLat],
16170
+ target
16171
+ } : null
16172
+ );
16173
+ return coordinate;
16174
+ });
16175
+ return () => {
16176
+ restorers.reverse().forEach((restore) => restore());
16177
+ };
16178
+ }
16179
+ function describeTarget(helper, winner, pointer) {
16180
+ if (!winner.feature) return { kind: "custom" };
16181
+ const feature2 = winner.feature.getGeoJson?.() ?? winner.feature.geoJson;
16182
+ if (!feature2) return null;
16183
+ const snapshot = structuredClone(feature2);
16184
+ const base = {
16185
+ featureId: winner.feature.id,
16186
+ feature: snapshot,
16187
+ temporary: !!winner.feature.temporary
16188
+ };
16189
+ if (winner.kind === "vertex") {
16190
+ let coordinatePath;
16191
+ visitGeometry(
16192
+ feature2.geometry,
16193
+ (position) => {
16194
+ if (!coordinatePath && position.coordinate[0] === winner.result.lngLat[0] && position.coordinate[1] === winner.result.lngLat[1])
16195
+ coordinatePath = [...position.path];
16196
+ },
16197
+ () => {
16198
+ }
16199
+ );
16200
+ return coordinatePath ? { ...base, kind: "vertex", coordinatePath } : null;
16201
+ }
16202
+ const screen = helper.gm.mapAdapter.project(pointer);
16203
+ let distance2 = Infinity;
16204
+ let segmentPaths;
16205
+ visitGeometry(
16206
+ feature2.geometry,
16207
+ () => {
16208
+ },
16209
+ (start, end) => {
16210
+ const a = helper.gm.mapAdapter.project(start.coordinate);
16211
+ const b = helper.gm.mapAdapter.project(end.coordinate);
16212
+ const dx = b[0] - a[0];
16213
+ const dy = b[1] - a[1];
16214
+ const lengthSquared = dx * dx + dy * dy;
16215
+ const fraction = lengthSquared === 0 ? 0 : Math.max(
16216
+ 0,
16217
+ Math.min(
16218
+ 1,
16219
+ ((screen[0] - a[0]) * dx + (screen[1] - a[1]) * dy) / lengthSquared
16220
+ )
16221
+ );
16222
+ const nearest = [a[0] + fraction * dx, a[1] + fraction * dy];
16223
+ const candidateDistance = Math.sqrt(
16224
+ (screen[0] - nearest[0]) ** 2 + (screen[1] - nearest[1]) ** 2
16225
+ );
16226
+ if (candidateDistance < distance2) {
16227
+ distance2 = candidateDistance;
16228
+ segmentPaths = [[...start.path], [...end.path]];
16229
+ }
16230
+ }
16231
+ );
16232
+ return segmentPaths ? { ...base, kind: "segment", segmentPaths } : null;
16233
+ }
16083
16234
  class HistoryManager {
16084
16235
  undoStack = [];
16085
16236
  redoStack = [];
@@ -16621,6 +16772,11 @@ const DEFAULT_OPTIONS = {
16621
16772
  showLabels: false,
16622
16773
  simplifyTolerance: 1e-3,
16623
16774
  snappingEnabled: true,
16775
+ snapEventsEnabled: false,
16776
+ onSnap: () => {
16777
+ },
16778
+ onUnsnap: () => {
16779
+ },
16624
16780
  topologyEnabled: false,
16625
16781
  measurementsEnabled: false,
16626
16782
  hideGeomanControl: true,
@@ -16657,7 +16813,8 @@ const DEFAULT_OPTIONS = {
16657
16813
  attributePanelMaxHeight: "80vh",
16658
16814
  attributePanelTop: 10,
16659
16815
  attributePanelSideOffset: 10,
16660
- attributePanelTitle: "Feature Properties"
16816
+ attributePanelTitle: "Feature Properties",
16817
+ createPopup: (options) => new maplibreGl.Popup(options)
16661
16818
  };
16662
16819
  const CSS_PREFIX = "geo-editor";
16663
16820
  const INTERNAL_IDS = {
@@ -18520,6 +18677,10 @@ function generateTempId() {
18520
18677
  class GeoEditor {
18521
18678
  map;
18522
18679
  geoman = null;
18680
+ observedSnappingHelper = null;
18681
+ detachSnapObserver = null;
18682
+ currentSnap = null;
18683
+ snapObserverRemoved = false;
18523
18684
  container;
18524
18685
  options;
18525
18686
  state;
@@ -18583,9 +18744,9 @@ class GeoEditor {
18583
18744
  toolbar = null;
18584
18745
  // Hidden file input for file dialog
18585
18746
  fileInput = null;
18586
- // Feature properties popup
18747
+ // Feature properties popup (built by `options.createPopup`)
18587
18748
  propertiesPopup = null;
18588
- // Numerical-rotation popup
18749
+ // Numerical-rotation popup (built by `options.createPopup`)
18589
18750
  rotatePopup = null;
18590
18751
  // History management (undo/redo)
18591
18752
  historyManager = null;
@@ -18640,6 +18801,7 @@ class GeoEditor {
18640
18801
  * Called when the control is added to the map
18641
18802
  */
18642
18803
  onAdd(map) {
18804
+ this.snapObserverRemoved = false;
18643
18805
  this.map = map;
18644
18806
  this.scaleFeature.init(map);
18645
18807
  this.lassoFeature.init(map);
@@ -18669,6 +18831,8 @@ class GeoEditor {
18669
18831
  * Called when the control is removed from the map
18670
18832
  */
18671
18833
  onRemove() {
18834
+ this.snapObserverRemoved = true;
18835
+ this.clearSnapObserver();
18672
18836
  this.removeKeyboardShortcuts();
18673
18837
  this.removeSelectionHandler();
18674
18838
  this.removeScaleHandler();
@@ -18699,6 +18863,8 @@ class GeoEditor {
18699
18863
  */
18700
18864
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
18701
18865
  setGeoman(geoman) {
18866
+ if (this.geoman === geoman) return;
18867
+ this.clearSnapObserver();
18702
18868
  this.geoman = geoman;
18703
18869
  this.setupGeomanEvents();
18704
18870
  this.applySnappingState();
@@ -18717,7 +18883,7 @@ class GeoEditor {
18717
18883
  const geoman = new Geoman(this.map);
18718
18884
  geoman.addControls = async () => {
18719
18885
  };
18720
- geoman.removeControls = () => {
18886
+ geoman.removeControls = async () => {
18721
18887
  };
18722
18888
  this.setGeoman(geoman);
18723
18889
  }
@@ -19143,7 +19309,7 @@ class GeoEditor {
19143
19309
  this.closeRotatePopup();
19144
19310
  }
19145
19311
  });
19146
- this.rotatePopup = new maplibreGl.Popup({
19312
+ this.rotatePopup = this.options.createPopup({
19147
19313
  maxWidth: "240px",
19148
19314
  closeButton: false,
19149
19315
  closeOnClick: false,
@@ -20009,7 +20175,7 @@ class GeoEditor {
20009
20175
  const centroid$1 = centroid(feature2);
20010
20176
  const coordinates = centroid$1.geometry.coordinates;
20011
20177
  const html = this.formatPropertiesHtml(feature2.properties);
20012
- this.propertiesPopup = new maplibreGl.Popup({
20178
+ this.propertiesPopup = this.options.createPopup({
20013
20179
  maxWidth: "300px",
20014
20180
  closeButton: true,
20015
20181
  closeOnClick: false,
@@ -21444,6 +21610,11 @@ class GeoEditor {
21444
21610
  );
21445
21611
  }
21446
21612
  applySnappingState() {
21613
+ if (!this.snappingEnabled) this.clearSnapObserver();
21614
+ this.applyGeomanSnappingMode();
21615
+ if (this.snappingEnabled) this.refreshSnapObserver();
21616
+ }
21617
+ applyGeomanSnappingMode() {
21447
21618
  if (!this.geoman) {
21448
21619
  return;
21449
21620
  }
@@ -21736,12 +21907,17 @@ class GeoEditor {
21736
21907
  }
21737
21908
  setupGeomanEvents() {
21738
21909
  if (!this.geoman) return;
21910
+ this.refreshSnapObserver();
21911
+ const observedGeoman = this.geoman;
21739
21912
  this.geoman.setGlobalEventsListener((event) => {
21913
+ if (this.snapObserverRemoved || this.geoman !== observedGeoman) return;
21914
+ this.refreshSnapObserver();
21740
21915
  const eventName = event.name ?? event.type ?? "";
21741
21916
  const eventFeature = this.extractFeatureFromEvent(
21742
21917
  event.feature
21743
21918
  );
21744
21919
  const eventAction = event.action ?? "";
21920
+ if (eventAction === "mode_end") this.updateSnap(null);
21745
21921
  if ((eventName === "gm:create" || event.type === "gm:create") && eventFeature) {
21746
21922
  if (this.state.activeDrawMode === "massing" && (eventFeature.geometry.type === "Polygon" || eventFeature.geometry.type === "MultiPolygon")) {
21747
21923
  eventFeature.properties = {
@@ -21813,6 +21989,56 @@ class GeoEditor {
21813
21989
  const event = new CustomEvent(type, { detail });
21814
21990
  this.map.getContainer().dispatchEvent(event);
21815
21991
  }
21992
+ /** Latest snap preview, copied for the caller. Not a committed topology edit. */
21993
+ getSnapTarget() {
21994
+ return this.currentSnap ? structuredClone(this.currentSnap) : null;
21995
+ }
21996
+ /** Whether the currently active Geoman snapping helper can be observed. */
21997
+ isSnapTrackingAvailable() {
21998
+ return this.detachSnapObserver !== null;
21999
+ }
22000
+ updateSnap(event) {
22001
+ const previous = this.currentSnap;
22002
+ const key = (snap) => {
22003
+ const target = snap.target;
22004
+ return target.kind === "custom" ? JSON.stringify(["custom", snap.coordinate]) : JSON.stringify([
22005
+ target.kind,
22006
+ target.featureId,
22007
+ target.temporary,
22008
+ target.kind === "vertex" ? target.coordinatePath : target.segmentPaths
22009
+ ]);
22010
+ };
22011
+ this.currentSnap = event;
22012
+ if (previous && (!event || key(previous) !== key(event))) {
22013
+ const detail = structuredClone(previous);
22014
+ this.options.onUnsnap?.(detail);
22015
+ if (this.map) this.emitEvent("gm:unsnap", detail);
22016
+ }
22017
+ if (event) {
22018
+ const detail = structuredClone(event);
22019
+ this.options.onSnap?.(detail);
22020
+ if (this.map) this.emitEvent("gm:snap", detail);
22021
+ }
22022
+ }
22023
+ clearSnapObserver() {
22024
+ this.detachSnapObserver?.();
22025
+ this.detachSnapObserver = null;
22026
+ this.observedSnappingHelper = null;
22027
+ this.updateSnap(null);
22028
+ }
22029
+ refreshSnapObserver() {
22030
+ if (this.snapObserverRemoved || !this.map || !this.options.snapEventsEnabled || !this.snappingEnabled) {
22031
+ return;
22032
+ }
22033
+ const helper = this.geoman?.actionInstances?.helper__snapping ?? null;
22034
+ if (helper === this.observedSnappingHelper) return;
22035
+ this.clearSnapObserver();
22036
+ this.observedSnappingHelper = helper;
22037
+ this.detachSnapObserver = observeSnapping(
22038
+ helper,
22039
+ (event) => this.updateSnap(event)
22040
+ );
22041
+ }
21816
22042
  // ============================================================================
21817
22043
  // History Management (Undo/Redo)
21818
22044
  // ============================================================================
@@ -22346,4 +22572,4 @@ exports.safeUnion = safeUnion;
22346
22572
  exports.selectFeaturesWithinLasso = selectFeaturesWithinLasso;
22347
22573
  exports.toSelectedFeatures = toSelectedFeatures;
22348
22574
  exports.toggleInSelection = toggleInSelection;
22349
- //# sourceMappingURL=geo-editor-C6-E5RN2.cjs.map
22575
+ //# sourceMappingURL=geo-editor-DgXTVVbG.cjs.map