maplibre-gl-geo-editor 0.1.0 → 0.3.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.
@@ -1 +1,2015 @@
1
+ import { Feature } from 'geojson';
2
+ import { FeatureCollection } from 'geojson';
3
+ import { GeoJsonProperties } from 'geojson';
4
+ import { Geometry } from 'geojson';
5
+ import { IControl } from 'maplibre-gl';
6
+ import { LineString } from 'geojson';
7
+ import { Map as Map_2 } from 'maplibre-gl';
8
+ import { MapMouseEvent } from 'maplibre-gl';
9
+ import { MapTouchEvent } from 'maplibre-gl';
10
+ import { MultiPolygon } from 'geojson';
11
+ import { Point } from 'geojson';
12
+ import { Polygon } from 'geojson';
13
+ import { Position } from 'geojson';
14
+ import * as turf from '@turf/turf';
15
+
16
+ /**
17
+ * Add feature to selection
18
+ */
19
+ export declare function addToSelection(selection: SelectedFeature[], feature: Feature, layerId?: string): SelectedFeature[];
20
+
21
+ /**
22
+ * Advanced edit modes (our implementations)
23
+ */
24
+ export declare const ADVANCED_EDIT_MODES: EditMode[];
25
+
26
+ /**
27
+ * Calculate the bearing between two points in degrees
28
+ */
29
+ export declare function bearingBetweenPoints(point1: Position, point2: Position): number;
30
+
31
+ /**
32
+ * Calculate the area of a polygon in square meters
33
+ */
34
+ export declare function calculateArea(feature: Feature<Polygon | MultiPolygon>): number;
35
+
36
+ /**
37
+ * Calculate the length of a line in kilometers
38
+ */
39
+ export declare function calculateLength(feature: Feature<LineString>): number;
40
+
41
+ /**
42
+ * Calculate the scale factor between two bounding boxes
43
+ */
44
+ export declare function calculateScaleFactor(originalBBox: [number, number, number, number], newBBox: [number, number, number, number]): number;
45
+
46
+ /**
47
+ * Check if features can be merged (union)
48
+ * At least 2 polygons that overlap or touch
49
+ */
50
+ export declare function canMergeFeatures(features: Feature[]): {
51
+ canMerge: boolean;
52
+ reason?: string;
53
+ };
54
+
55
+ /**
56
+ * Check if features can be used for difference operation
57
+ */
58
+ export declare function canSubtractFeatures(features: Feature[]): {
59
+ canSubtract: boolean;
60
+ reason?: string;
61
+ };
62
+
63
+ /**
64
+ * Clamp a value between min and max
65
+ */
66
+ export declare function clamp(value: number, min: number, max: number): number;
67
+
68
+ /**
69
+ * Deep clone a feature
70
+ */
71
+ export declare function cloneFeature<T extends Feature>(feature: T): T;
72
+
73
+ /**
74
+ * Check if polygon1 contains polygon2
75
+ */
76
+ export declare function contains(container: Feature<Polygon | MultiPolygon>, contained: Feature<Polygon | MultiPolygon>): boolean;
77
+
78
+ /**
79
+ * Handles copy/paste operations for features
80
+ */
81
+ export declare class CopyFeature {
82
+ private options;
83
+ constructor(options?: CopyOptions);
84
+ /**
85
+ * Copy a single feature with optional offset
86
+ */
87
+ copy(feature: Feature, offset?: [number, number]): Feature;
88
+ /**
89
+ * Copy multiple features maintaining relative positions
90
+ */
91
+ copyMultiple(features: Feature[], offset?: [number, number]): Feature[];
92
+ /**
93
+ * Copy features to a specific location (centered on the location)
94
+ */
95
+ copyToLocation(features: Feature[], targetCenter: [number, number]): Feature[];
96
+ /**
97
+ * Update the default offset
98
+ */
99
+ setOffset(offset: [number, number]): void;
100
+ /**
101
+ * Get the current offset
102
+ */
103
+ getOffset(): [number, number];
104
+ }
105
+
106
+ export declare interface CopyOptions {
107
+ /** Offset in [lng, lat] degrees for pasted features */
108
+ offset?: [number, number];
109
+ /** Generate new IDs for copied features */
110
+ generateNewIds?: boolean;
111
+ }
112
+
113
+ /**
114
+ * Create a feature collection
115
+ */
116
+ export declare function createFeatureCollection<T extends Feature>(features: T[]): FeatureCollection;
117
+
118
+ /**
119
+ * Create a line from coordinates
120
+ */
121
+ export declare function createLine(coordinates: Position[], properties?: Record<string, unknown>): Feature<LineString>;
122
+
123
+ /**
124
+ * Create a point from coordinates
125
+ */
126
+ export declare function createPoint(coordinates: Position, properties?: Record<string, unknown>): Feature<Point>;
127
+
128
+ /**
129
+ * Create a polygon from coordinates
130
+ */
131
+ export declare function createPolygon(coordinates: Position[][], properties?: Record<string, unknown>): Feature<Polygon>;
132
+
133
+ /**
134
+ * CSS class prefix for the plugin
135
+ */
136
+ export declare const CSS_PREFIX = "geo-editor";
137
+
138
+ /**
139
+ * Default draw modes available in the toolbar
140
+ */
141
+ export declare const DEFAULT_DRAW_MODES: DrawMode[];
142
+
143
+ /**
144
+ * Default edit modes available in the toolbar
145
+ */
146
+ export declare const DEFAULT_EDIT_MODES: EditMode[];
147
+
148
+ /**
149
+ * Default file modes
150
+ */
151
+ export declare const DEFAULT_FILE_MODES: FileMode[];
152
+
153
+ /**
154
+ * Default options for GeoEditor
155
+ */
156
+ export declare const DEFAULT_OPTIONS: GeoEditorOptionsRequired;
157
+
158
+ /**
159
+ * Convert degrees to radians
160
+ */
161
+ export declare function degreesToRadians(degrees: number): number;
162
+
163
+ /**
164
+ * Handles polygon difference/subtraction operations
165
+ */
166
+ export declare class DifferenceFeature {
167
+ /**
168
+ * Subtract one or more polygons from a base polygon
169
+ */
170
+ difference(base: Feature<Polygon | MultiPolygon>, subtract: Feature<Polygon | MultiPolygon>[], options?: DifferenceOptions): DifferenceResult;
171
+ /**
172
+ * Check if subtraction can be performed
173
+ */
174
+ canSubtract(base: Feature<Polygon | MultiPolygon>, subtract: Feature<Polygon | MultiPolygon>): {
175
+ canSubtract: boolean;
176
+ overlap: boolean;
177
+ reason?: string;
178
+ };
179
+ /**
180
+ * Get the area that would be removed
181
+ */
182
+ getSubtractedArea(base: Feature<Polygon | MultiPolygon>, subtract: Feature<Polygon | MultiPolygon>): number | null;
183
+ /**
184
+ * Preview the result without applying
185
+ */
186
+ preview(base: Feature<Polygon | MultiPolygon>, subtract: Feature<Polygon | MultiPolygon>[]): Feature<Polygon | MultiPolygon> | null;
187
+ /**
188
+ * Create a hole in a polygon at a specific location
189
+ */
190
+ createHole(polygon: Feature<Polygon>, hole: Feature<Polygon>): Feature<Polygon | MultiPolygon> | null;
191
+ }
192
+
193
+ export declare interface DifferenceOptions {
194
+ /** Properties to use for the result feature */
195
+ properties?: GeoJsonProperties;
196
+ }
197
+
198
+ export declare interface DifferenceResult {
199
+ /** Resulting feature after subtraction */
200
+ result: Feature<Polygon | MultiPolygon> | null;
201
+ /** Base feature */
202
+ base: Feature<Polygon | MultiPolygon>;
203
+ /** Features that were subtracted */
204
+ subtracted: Feature<Polygon | MultiPolygon>[];
205
+ /** Whether the operation was successful */
206
+ success: boolean;
207
+ /** Error message if operation failed */
208
+ error?: string;
209
+ }
210
+
211
+ /**
212
+ * Calculate the distance between two points in kilometers
213
+ */
214
+ export declare function distanceBetweenPoints(point1: Position, point2: Position): number;
215
+
216
+ /**
217
+ * Available draw modes.
218
+ * Note: 'freehand' is implemented as a custom feature (not dependent on Geoman Pro).
219
+ */
220
+ export declare type DrawMode = 'marker' | 'circle' | 'circle_marker' | 'ellipse' | 'text_marker' | 'line' | 'rectangle' | 'polygon' | 'freehand';
221
+
222
+ /**
223
+ * Available draw modes.
224
+ * Note: 'freehand' is implemented as a custom feature (not dependent on Geoman Pro).
225
+ */
226
+ declare type DrawMode_2 = 'marker' | 'circle' | 'circle_marker' | 'ellipse' | 'text_marker' | 'line' | 'rectangle' | 'polygon' | 'freehand';
227
+
228
+ export declare type EditMode = 'drag' | 'change' | 'rotate' | 'cut' | 'delete' | 'select' | 'scale' | 'copy' | 'split' | 'union' | 'difference' | 'simplify' | 'lasso';
229
+
230
+ declare type EditMode_2 = 'drag' | 'change' | 'rotate' | 'cut' | 'delete' | 'select' | 'scale' | 'copy' | 'split' | 'union' | 'difference' | 'simplify' | 'lasso';
231
+
232
+ /**
233
+ * Ensure a feature has an ID
234
+ */
235
+ export declare function ensureFeatureId(feature: Feature): Feature;
236
+
237
+ export declare type FileMode = 'open' | 'save';
238
+
239
+ declare type FileMode_2 = 'open' | 'save';
240
+
241
+ /**
242
+ * Filter features by geometry type
243
+ */
244
+ export declare function filterByGeometryType(features: Feature[], types: string[]): Feature[];
245
+
246
+ /**
247
+ * Convert SelectedFeature array to Feature array
248
+ */
249
+ export declare function fromSelectedFeatures(selected: SelectedFeature[]): Feature[];
250
+
251
+ /**
252
+ * Generate a unique ID for a feature
253
+ */
254
+ export declare function generateFeatureId(): string;
255
+
256
+ /**
257
+ * GeoEditor - Advanced geometry editing control for MapLibre GL
258
+ * Extends the free Geoman control with advanced features
259
+ */
260
+ export declare class GeoEditor implements IControl {
261
+ private map;
262
+ private geoman;
263
+ private container;
264
+ private options;
265
+ private state;
266
+ private copyFeature;
267
+ private simplifyFeature;
268
+ private unionFeature;
269
+ private differenceFeature;
270
+ private scaleFeature;
271
+ private lassoFeature;
272
+ private splitFeature;
273
+ private freehandFeature;
274
+ private boundKeyHandler;
275
+ private boundClickHandler;
276
+ private boundScaleMouseDown;
277
+ private boundScaleMouseMove;
278
+ private boundScaleMouseUp;
279
+ private isSelectMode;
280
+ private pendingOperation;
281
+ private snappingEnabled;
282
+ private lastCreatedFeature;
283
+ private lastEditedFeature;
284
+ private lastDeletedFeature;
285
+ private lastDeletedFeatureId;
286
+ private isScaling;
287
+ private scaleTargetFeature;
288
+ private scaleTargetGeomanData;
289
+ private scaleStartFeature;
290
+ private scaleDragPanEnabled;
291
+ private isMultiDragging;
292
+ private multiDragStartPoint;
293
+ private multiDragOriginalFeatures;
294
+ private multiDragGeomanData;
295
+ private multiDragPanEnabled;
296
+ private boundMultiDragMouseDown;
297
+ private boundMultiDragMouseMove;
298
+ private boundMultiDragMouseUp;
299
+ private toolbar;
300
+ private fileInput;
301
+ private propertiesPopup;
302
+ constructor(options?: GeoEditorOptions);
303
+ /**
304
+ * Called when the control is added to the map
305
+ */
306
+ onAdd(map: Map_2): HTMLElement;
307
+ /**
308
+ * Called when the control is removed from the map
309
+ */
310
+ onRemove(): void;
311
+ /**
312
+ * Set the Geoman instance for integration
313
+ */
314
+ setGeoman(geoman: GeomanInstance): void;
315
+ /**
316
+ * Hide the geoman control toolbar
317
+ */
318
+ private hideGeomanControl;
319
+ /**
320
+ * Setup click handler for feature selection
321
+ */
322
+ private setupSelectionHandler;
323
+ /**
324
+ * Find a feature at a given point
325
+ */
326
+ private findFeatureAtPoint;
327
+ /**
328
+ * Find a feature at the mouse event using Geoman's hit test
329
+ */
330
+ private findFeatureByMouseEvent;
331
+ /**
332
+ * Find geoman data for a feature by searching
333
+ */
334
+ private findGeomanDataForFeature;
335
+ private getGeomanIdFromFeature;
336
+ private getGeomanFeature;
337
+ /**
338
+ * Remove selection handler
339
+ */
340
+ private removeSelectionHandler;
341
+ /**
342
+ * Setup mouse handlers for scale mode
343
+ */
344
+ private setupScaleHandler;
345
+ /**
346
+ * Remove scale handlers
347
+ */
348
+ private removeScaleHandler;
349
+ /**
350
+ * Setup mouse handlers for multi-drag when multiple features are selected
351
+ */
352
+ private setupMultiDragHandler;
353
+ private removeMultiDragHandler;
354
+ private disableMultiDragPan;
355
+ private restoreMultiDragPan;
356
+ private getScaleHandleFromEvent;
357
+ private disableScaleDragPan;
358
+ private restoreScaleDragPan;
359
+ private applyScaledFeature;
360
+ private bringScaleHandlesToFront;
361
+ private logSelectedFeatureCollection;
362
+ private extractFeatureFromEvent;
363
+ /**
364
+ * Toggle feature in selection
365
+ */
366
+ private toggleFeatureSelection;
367
+ /**
368
+ * Enable select mode
369
+ */
370
+ enableSelectMode(): void;
371
+ /**
372
+ * Disable select mode
373
+ */
374
+ disableSelectMode(): void;
375
+ /**
376
+ * Get the current state
377
+ */
378
+ getState(): GeoEditorState;
379
+ /**
380
+ * Get selected features
381
+ */
382
+ getSelectedFeatures(): Feature[];
383
+ getSelectedFeatureCollection(): FeatureCollection;
384
+ /**
385
+ * Get all features from the map
386
+ */
387
+ getFeatures(): FeatureCollection;
388
+ getAllFeatureCollection(): FeatureCollection;
389
+ getLastCreatedFeature(): Feature | null;
390
+ getLastEditedFeature(): Feature | null;
391
+ getLastDeletedFeature(): Feature | null;
392
+ getLastDeletedFeatureId(): string | null;
393
+ /**
394
+ * Enable a draw mode
395
+ */
396
+ enableDrawMode(mode: DrawMode): void;
397
+ /**
398
+ * Enable freehand drawing mode (custom implementation)
399
+ */
400
+ private enableFreehandMode;
401
+ /**
402
+ * Disable freehand drawing mode
403
+ */
404
+ private disableFreehandMode;
405
+ /**
406
+ * Enable an edit mode
407
+ */
408
+ enableEditMode(mode: EditMode): void;
409
+ /**
410
+ * Disable all modes
411
+ */
412
+ disableAllModes(): void;
413
+ /**
414
+ * Enable an advanced edit mode
415
+ */
416
+ private enableAdvancedEditMode;
417
+ /**
418
+ * Enable union mode (interactive polygon selection)
419
+ */
420
+ private enableUnionMode;
421
+ /**
422
+ * Enable difference mode (interactive polygon selection)
423
+ */
424
+ private enableDifferenceMode;
425
+ /**
426
+ * Execute the pending operation (union/difference)
427
+ */
428
+ executePendingOperation(): void;
429
+ /**
430
+ * Cancel pending operation
431
+ */
432
+ cancelPendingOperation(): void;
433
+ /**
434
+ * Setup selection highlight layer
435
+ */
436
+ private setupSelectionHighlight;
437
+ /**
438
+ * Update selection highlight on the map
439
+ */
440
+ private updateSelectionHighlight;
441
+ /**
442
+ * Select features
443
+ */
444
+ selectFeatures(features: Feature[], geomanDataList?: GeomanFeatureData_2[]): void;
445
+ /**
446
+ * Add feature to selection
447
+ */
448
+ addToSelection(feature: Feature, geomanData?: GeomanFeatureData_2): void;
449
+ /**
450
+ * Remove feature from selection
451
+ */
452
+ removeFromSelection(featureId: string): void;
453
+ /**
454
+ * Clear selection
455
+ */
456
+ clearSelection(): void;
457
+ /**
458
+ * Show popup with feature properties
459
+ */
460
+ private showFeaturePropertiesPopup;
461
+ /**
462
+ * Hide feature properties popup
463
+ */
464
+ private hideFeaturePropertiesPopup;
465
+ /**
466
+ * Format feature properties as HTML table
467
+ */
468
+ private formatPropertiesHtml;
469
+ /**
470
+ * Escape HTML special characters
471
+ */
472
+ private escapeHtml;
473
+ /**
474
+ * Enable scale mode
475
+ */
476
+ private enableScaleMode;
477
+ /**
478
+ * Enable copy mode
479
+ */
480
+ private enableCopyMode;
481
+ /**
482
+ * Enable split mode
483
+ */
484
+ private enableSplitMode;
485
+ /**
486
+ * Enable lasso selection mode
487
+ */
488
+ private enableLassoMode;
489
+ /**
490
+ * Execute union on selected polygons
491
+ */
492
+ private executeUnion;
493
+ /**
494
+ * Execute difference on selected polygons
495
+ */
496
+ private executeDifference;
497
+ /**
498
+ * Execute simplify on selected features
499
+ */
500
+ private executeSimplify;
501
+ private getSimplifyResult;
502
+ /**
503
+ * Copy selected features to clipboard
504
+ */
505
+ copySelectedFeatures(): void;
506
+ /**
507
+ * Paste features from clipboard
508
+ */
509
+ pasteFeatures(): void;
510
+ /**
511
+ * Delete a feature by ID
512
+ */
513
+ private deleteFeatureById;
514
+ /**
515
+ * Delete selected features
516
+ */
517
+ deleteSelectedFeatures(): void;
518
+ private deleteGeomanFeatureData;
519
+ private deleteGeomanFeatures;
520
+ private clearGeomanTemporaryFeatures;
521
+ private handleSplitResult;
522
+ private handleUnionResult;
523
+ private handleDifferenceResult;
524
+ private applySimplifyResult;
525
+ private handleLassoResult;
526
+ /**
527
+ * Create the toolbar UI
528
+ */
529
+ private createToolbar;
530
+ /**
531
+ * Create the collapse/expand button
532
+ */
533
+ private createCollapseButton;
534
+ /**
535
+ * Toggle toolbar collapsed state
536
+ */
537
+ toggleCollapse(): void;
538
+ /**
539
+ * Check if toolbar is collapsed
540
+ */
541
+ isCollapsed(): boolean;
542
+ /**
543
+ * Set toolbar collapsed state
544
+ */
545
+ setCollapsed(collapsed: boolean): void;
546
+ /**
547
+ * Create helper tools group (snapping toggle)
548
+ */
549
+ private createHelperToolsGroup;
550
+ private createResetToolsGroup;
551
+ /**
552
+ * Create file tools group (open/save GeoJSON)
553
+ */
554
+ private createFileToolsGroup;
555
+ /**
556
+ * Setup hidden file input for file dialog
557
+ */
558
+ private setupFileInput;
559
+ /**
560
+ * Open file dialog to select GeoJSON file
561
+ */
562
+ openFileDialog(): void;
563
+ /**
564
+ * Handle file selection from file dialog
565
+ */
566
+ private handleFileSelect;
567
+ /**
568
+ * Load GeoJSON data into the editor
569
+ * @param geoJson - FeatureCollection or Feature to load
570
+ * @param filename - Optional filename for logging
571
+ * @returns Result of the load operation
572
+ */
573
+ loadGeoJson(geoJson: FeatureCollection | Feature, filename?: string): GeoJsonLoadResult;
574
+ /**
575
+ * Fit the map bounds to show all features in a FeatureCollection
576
+ */
577
+ private fitBoundsToFeatures;
578
+ /**
579
+ * Check if a bounding box is valid
580
+ */
581
+ private isValidBBox;
582
+ /**
583
+ * Fit the map to show all current features
584
+ */
585
+ fitToAllFeatures(): void;
586
+ /**
587
+ * Save current features as GeoJSON file download
588
+ * @param filename - Optional filename for download
589
+ * @returns Result of the save operation
590
+ */
591
+ saveGeoJson(filename?: string): GeoJsonSaveResult;
592
+ /**
593
+ * Toggle snapping on/off (independent of other modes)
594
+ * Note: Snapping functionality requires Geoman Pro. In the free version,
595
+ * this toggle tracks state but does not enable actual vertex snapping.
596
+ */
597
+ toggleSnapping(): void;
598
+ /**
599
+ * Check if snapping is enabled
600
+ */
601
+ isSnappingEnabled(): boolean;
602
+ /**
603
+ * Set snapping state
604
+ */
605
+ setSnapping(enabled: boolean): void;
606
+ private applySnappingState;
607
+ /**
608
+ * Create a tool group
609
+ */
610
+ private createToolGroup;
611
+ /**
612
+ * Create a tool button
613
+ */
614
+ private createToolButton;
615
+ /**
616
+ * Update toolbar button states
617
+ */
618
+ private updateToolbarState;
619
+ /**
620
+ * Get human-readable label for a mode
621
+ */
622
+ private getModeLabel;
623
+ /**
624
+ * Get SVG icon for a mode
625
+ */
626
+ private getModeIcon;
627
+ private setupKeyboardShortcuts;
628
+ private removeKeyboardShortcuts;
629
+ private setupGeomanEvents;
630
+ private emitEvent;
631
+ }
632
+
633
+ /**
634
+ * GeoEditor - Advanced geometry editing control for MapLibre GL
635
+ * Extends the free Geoman control with advanced features
636
+ */
637
+ declare class GeoEditor_2 implements IControl {
638
+ private map;
639
+ private geoman;
640
+ private container;
641
+ private options;
642
+ private state;
643
+ private copyFeature;
644
+ private simplifyFeature;
645
+ private unionFeature;
646
+ private differenceFeature;
647
+ private scaleFeature;
648
+ private lassoFeature;
649
+ private splitFeature;
650
+ private freehandFeature;
651
+ private boundKeyHandler;
652
+ private boundClickHandler;
653
+ private boundScaleMouseDown;
654
+ private boundScaleMouseMove;
655
+ private boundScaleMouseUp;
656
+ private isSelectMode;
657
+ private pendingOperation;
658
+ private snappingEnabled;
659
+ private lastCreatedFeature;
660
+ private lastEditedFeature;
661
+ private lastDeletedFeature;
662
+ private lastDeletedFeatureId;
663
+ private isScaling;
664
+ private scaleTargetFeature;
665
+ private scaleTargetGeomanData;
666
+ private scaleStartFeature;
667
+ private scaleDragPanEnabled;
668
+ private isMultiDragging;
669
+ private multiDragStartPoint;
670
+ private multiDragOriginalFeatures;
671
+ private multiDragGeomanData;
672
+ private multiDragPanEnabled;
673
+ private boundMultiDragMouseDown;
674
+ private boundMultiDragMouseMove;
675
+ private boundMultiDragMouseUp;
676
+ private toolbar;
677
+ private fileInput;
678
+ private propertiesPopup;
679
+ constructor(options?: GeoEditorOptions_2);
680
+ /**
681
+ * Called when the control is added to the map
682
+ */
683
+ onAdd(map: Map_2): HTMLElement;
684
+ /**
685
+ * Called when the control is removed from the map
686
+ */
687
+ onRemove(): void;
688
+ /**
689
+ * Set the Geoman instance for integration
690
+ */
691
+ setGeoman(geoman: GeomanInstance_2): void;
692
+ /**
693
+ * Hide the geoman control toolbar
694
+ */
695
+ private hideGeomanControl;
696
+ /**
697
+ * Setup click handler for feature selection
698
+ */
699
+ private setupSelectionHandler;
700
+ /**
701
+ * Find a feature at a given point
702
+ */
703
+ private findFeatureAtPoint;
704
+ /**
705
+ * Find a feature at the mouse event using Geoman's hit test
706
+ */
707
+ private findFeatureByMouseEvent;
708
+ /**
709
+ * Find geoman data for a feature by searching
710
+ */
711
+ private findGeomanDataForFeature;
712
+ private getGeomanIdFromFeature;
713
+ private getGeomanFeature;
714
+ /**
715
+ * Remove selection handler
716
+ */
717
+ private removeSelectionHandler;
718
+ /**
719
+ * Setup mouse handlers for scale mode
720
+ */
721
+ private setupScaleHandler;
722
+ /**
723
+ * Remove scale handlers
724
+ */
725
+ private removeScaleHandler;
726
+ /**
727
+ * Setup mouse handlers for multi-drag when multiple features are selected
728
+ */
729
+ private setupMultiDragHandler;
730
+ private removeMultiDragHandler;
731
+ private disableMultiDragPan;
732
+ private restoreMultiDragPan;
733
+ private getScaleHandleFromEvent;
734
+ private disableScaleDragPan;
735
+ private restoreScaleDragPan;
736
+ private applyScaledFeature;
737
+ private bringScaleHandlesToFront;
738
+ private logSelectedFeatureCollection;
739
+ private extractFeatureFromEvent;
740
+ /**
741
+ * Toggle feature in selection
742
+ */
743
+ private toggleFeatureSelection;
744
+ /**
745
+ * Enable select mode
746
+ */
747
+ enableSelectMode(): void;
748
+ /**
749
+ * Disable select mode
750
+ */
751
+ disableSelectMode(): void;
752
+ /**
753
+ * Get the current state
754
+ */
755
+ getState(): GeoEditorState_2;
756
+ /**
757
+ * Get selected features
758
+ */
759
+ getSelectedFeatures(): Feature[];
760
+ getSelectedFeatureCollection(): FeatureCollection;
761
+ /**
762
+ * Get all features from the map
763
+ */
764
+ getFeatures(): FeatureCollection;
765
+ getAllFeatureCollection(): FeatureCollection;
766
+ getLastCreatedFeature(): Feature | null;
767
+ getLastEditedFeature(): Feature | null;
768
+ getLastDeletedFeature(): Feature | null;
769
+ getLastDeletedFeatureId(): string | null;
770
+ /**
771
+ * Enable a draw mode
772
+ */
773
+ enableDrawMode(mode: DrawMode_2): void;
774
+ /**
775
+ * Enable freehand drawing mode (custom implementation)
776
+ */
777
+ private enableFreehandMode;
778
+ /**
779
+ * Disable freehand drawing mode
780
+ */
781
+ private disableFreehandMode;
782
+ /**
783
+ * Enable an edit mode
784
+ */
785
+ enableEditMode(mode: EditMode_2): void;
786
+ /**
787
+ * Disable all modes
788
+ */
789
+ disableAllModes(): void;
790
+ /**
791
+ * Enable an advanced edit mode
792
+ */
793
+ private enableAdvancedEditMode;
794
+ /**
795
+ * Enable union mode (interactive polygon selection)
796
+ */
797
+ private enableUnionMode;
798
+ /**
799
+ * Enable difference mode (interactive polygon selection)
800
+ */
801
+ private enableDifferenceMode;
802
+ /**
803
+ * Execute the pending operation (union/difference)
804
+ */
805
+ executePendingOperation(): void;
806
+ /**
807
+ * Cancel pending operation
808
+ */
809
+ cancelPendingOperation(): void;
810
+ /**
811
+ * Setup selection highlight layer
812
+ */
813
+ private setupSelectionHighlight;
814
+ /**
815
+ * Update selection highlight on the map
816
+ */
817
+ private updateSelectionHighlight;
818
+ /**
819
+ * Select features
820
+ */
821
+ selectFeatures(features: Feature[], geomanDataList?: GeomanFeatureData[]): void;
822
+ /**
823
+ * Add feature to selection
824
+ */
825
+ addToSelection(feature: Feature, geomanData?: GeomanFeatureData): void;
826
+ /**
827
+ * Remove feature from selection
828
+ */
829
+ removeFromSelection(featureId: string): void;
830
+ /**
831
+ * Clear selection
832
+ */
833
+ clearSelection(): void;
834
+ /**
835
+ * Show popup with feature properties
836
+ */
837
+ private showFeaturePropertiesPopup;
838
+ /**
839
+ * Hide feature properties popup
840
+ */
841
+ private hideFeaturePropertiesPopup;
842
+ /**
843
+ * Format feature properties as HTML table
844
+ */
845
+ private formatPropertiesHtml;
846
+ /**
847
+ * Escape HTML special characters
848
+ */
849
+ private escapeHtml;
850
+ /**
851
+ * Enable scale mode
852
+ */
853
+ private enableScaleMode;
854
+ /**
855
+ * Enable copy mode
856
+ */
857
+ private enableCopyMode;
858
+ /**
859
+ * Enable split mode
860
+ */
861
+ private enableSplitMode;
862
+ /**
863
+ * Enable lasso selection mode
864
+ */
865
+ private enableLassoMode;
866
+ /**
867
+ * Execute union on selected polygons
868
+ */
869
+ private executeUnion;
870
+ /**
871
+ * Execute difference on selected polygons
872
+ */
873
+ private executeDifference;
874
+ /**
875
+ * Execute simplify on selected features
876
+ */
877
+ private executeSimplify;
878
+ private getSimplifyResult;
879
+ /**
880
+ * Copy selected features to clipboard
881
+ */
882
+ copySelectedFeatures(): void;
883
+ /**
884
+ * Paste features from clipboard
885
+ */
886
+ pasteFeatures(): void;
887
+ /**
888
+ * Delete a feature by ID
889
+ */
890
+ private deleteFeatureById;
891
+ /**
892
+ * Delete selected features
893
+ */
894
+ deleteSelectedFeatures(): void;
895
+ private deleteGeomanFeatureData;
896
+ private deleteGeomanFeatures;
897
+ private clearGeomanTemporaryFeatures;
898
+ private handleSplitResult;
899
+ private handleUnionResult;
900
+ private handleDifferenceResult;
901
+ private applySimplifyResult;
902
+ private handleLassoResult;
903
+ /**
904
+ * Create the toolbar UI
905
+ */
906
+ private createToolbar;
907
+ /**
908
+ * Create the collapse/expand button
909
+ */
910
+ private createCollapseButton;
911
+ /**
912
+ * Toggle toolbar collapsed state
913
+ */
914
+ toggleCollapse(): void;
915
+ /**
916
+ * Check if toolbar is collapsed
917
+ */
918
+ isCollapsed(): boolean;
919
+ /**
920
+ * Set toolbar collapsed state
921
+ */
922
+ setCollapsed(collapsed: boolean): void;
923
+ /**
924
+ * Create helper tools group (snapping toggle)
925
+ */
926
+ private createHelperToolsGroup;
927
+ private createResetToolsGroup;
928
+ /**
929
+ * Create file tools group (open/save GeoJSON)
930
+ */
931
+ private createFileToolsGroup;
932
+ /**
933
+ * Setup hidden file input for file dialog
934
+ */
935
+ private setupFileInput;
936
+ /**
937
+ * Open file dialog to select GeoJSON file
938
+ */
939
+ openFileDialog(): void;
940
+ /**
941
+ * Handle file selection from file dialog
942
+ */
943
+ private handleFileSelect;
944
+ /**
945
+ * Load GeoJSON data into the editor
946
+ * @param geoJson - FeatureCollection or Feature to load
947
+ * @param filename - Optional filename for logging
948
+ * @returns Result of the load operation
949
+ */
950
+ loadGeoJson(geoJson: FeatureCollection | Feature, filename?: string): GeoJsonLoadResult_2;
951
+ /**
952
+ * Fit the map bounds to show all features in a FeatureCollection
953
+ */
954
+ private fitBoundsToFeatures;
955
+ /**
956
+ * Check if a bounding box is valid
957
+ */
958
+ private isValidBBox;
959
+ /**
960
+ * Fit the map to show all current features
961
+ */
962
+ fitToAllFeatures(): void;
963
+ /**
964
+ * Save current features as GeoJSON file download
965
+ * @param filename - Optional filename for download
966
+ * @returns Result of the save operation
967
+ */
968
+ saveGeoJson(filename?: string): GeoJsonSaveResult_2;
969
+ /**
970
+ * Toggle snapping on/off (independent of other modes)
971
+ * Note: Snapping functionality requires Geoman Pro. In the free version,
972
+ * this toggle tracks state but does not enable actual vertex snapping.
973
+ */
974
+ toggleSnapping(): void;
975
+ /**
976
+ * Check if snapping is enabled
977
+ */
978
+ isSnappingEnabled(): boolean;
979
+ /**
980
+ * Set snapping state
981
+ */
982
+ setSnapping(enabled: boolean): void;
983
+ private applySnappingState;
984
+ /**
985
+ * Create a tool group
986
+ */
987
+ private createToolGroup;
988
+ /**
989
+ * Create a tool button
990
+ */
991
+ private createToolButton;
992
+ /**
993
+ * Update toolbar button states
994
+ */
995
+ private updateToolbarState;
996
+ /**
997
+ * Get human-readable label for a mode
998
+ */
999
+ private getModeLabel;
1000
+ /**
1001
+ * Get SVG icon for a mode
1002
+ */
1003
+ private getModeIcon;
1004
+ private setupKeyboardShortcuts;
1005
+ private removeKeyboardShortcuts;
1006
+ private setupGeomanEvents;
1007
+ private emitEvent;
1008
+ }
1009
+
1010
+ export declare interface GeoEditorEventMap {
1011
+ 'gm:scale': {
1012
+ feature: Feature;
1013
+ scaleFactor: number;
1014
+ };
1015
+ 'gm:scalestart': {
1016
+ feature: Feature;
1017
+ };
1018
+ 'gm:scaleend': {
1019
+ feature: Feature;
1020
+ scaleFactor: number;
1021
+ };
1022
+ 'gm:copy': {
1023
+ features: Feature[];
1024
+ };
1025
+ 'gm:paste': {
1026
+ features: Feature[];
1027
+ };
1028
+ 'gm:split': SplitResult;
1029
+ 'gm:union': UnionResult;
1030
+ 'gm:difference': DifferenceResult;
1031
+ 'gm:simplify': SimplifyResult;
1032
+ 'gm:lassostart': Record<string, never>;
1033
+ 'gm:lassoend': LassoResult;
1034
+ 'gm:selectionchange': {
1035
+ features: Feature[];
1036
+ };
1037
+ 'gm:modechange': {
1038
+ mode: DrawMode | EditMode | null;
1039
+ };
1040
+ 'gm:geojsonload': GeoJsonLoadResult;
1041
+ 'gm:geojsonsave': GeoJsonSaveResult;
1042
+ }
1043
+
1044
+ export declare type GeoEditorEventType = keyof GeoEditorEventMap;
1045
+
1046
+ export declare interface GeoEditorOptions {
1047
+ /** Position of the control on the map */
1048
+ position?: ToolbarPosition;
1049
+ /** Whether the toolbar starts collapsed */
1050
+ collapsed?: boolean;
1051
+ /** Draw modes to enable */
1052
+ drawModes?: DrawMode[];
1053
+ /** Edit modes to enable */
1054
+ editModes?: EditMode[];
1055
+ /** Helper modes to enable */
1056
+ helperModes?: HelperMode[];
1057
+ /** Toolbar orientation */
1058
+ toolbarOrientation?: ToolbarOrientation;
1059
+ /** Show text labels on toolbar buttons */
1060
+ showLabels?: boolean;
1061
+ /** Default tolerance for line simplification */
1062
+ simplifyTolerance?: number;
1063
+ /** Enable snapping by default */
1064
+ snappingEnabled?: boolean;
1065
+ /** Enable measurements by default */
1066
+ measurementsEnabled?: boolean;
1067
+ /** Hide the geoman control (use GeoEditor toolbar instead) */
1068
+ hideGeomanControl?: boolean;
1069
+ /** Callback when a feature is created */
1070
+ onFeatureCreate?: (feature: Feature) => void;
1071
+ /** Callback when a feature is edited */
1072
+ onFeatureEdit?: (feature: Feature, oldFeature: Feature) => void;
1073
+ /** Callback when a feature is deleted */
1074
+ onFeatureDelete?: (featureId: string) => void;
1075
+ /** Callback when selection changes */
1076
+ onSelectionChange?: (features: Feature[]) => void;
1077
+ /** Callback when mode changes */
1078
+ onModeChange?: (mode: DrawMode | EditMode | null) => void;
1079
+ /** File modes to enable (default: ['open', 'save']) */
1080
+ fileModes?: FileMode[];
1081
+ /** Default filename for saving GeoJSON (default: 'features.geojson') */
1082
+ saveFilename?: string;
1083
+ /** Callback when GeoJSON is loaded */
1084
+ onGeoJsonLoad?: (result: GeoJsonLoadResult) => void;
1085
+ /** Callback when GeoJSON is saved */
1086
+ onGeoJsonSave?: (result: GeoJsonSaveResult) => void;
1087
+ /** Show feature properties in a popup when selected (default: false) */
1088
+ showFeatureProperties?: boolean;
1089
+ /** Auto-fit map bounds when GeoJSON is loaded (default: true) */
1090
+ fitBoundsOnLoad?: boolean;
1091
+ /** Number of columns for button layout in vertical orientation (default: 1) */
1092
+ columns?: number;
1093
+ }
1094
+
1095
+ declare interface GeoEditorOptions_2 {
1096
+ /** Position of the control on the map */
1097
+ position?: ToolbarPosition_2;
1098
+ /** Whether the toolbar starts collapsed */
1099
+ collapsed?: boolean;
1100
+ /** Draw modes to enable */
1101
+ drawModes?: DrawMode_2[];
1102
+ /** Edit modes to enable */
1103
+ editModes?: EditMode_2[];
1104
+ /** Helper modes to enable */
1105
+ helperModes?: HelperMode_2[];
1106
+ /** Toolbar orientation */
1107
+ toolbarOrientation?: ToolbarOrientation_2;
1108
+ /** Show text labels on toolbar buttons */
1109
+ showLabels?: boolean;
1110
+ /** Default tolerance for line simplification */
1111
+ simplifyTolerance?: number;
1112
+ /** Enable snapping by default */
1113
+ snappingEnabled?: boolean;
1114
+ /** Enable measurements by default */
1115
+ measurementsEnabled?: boolean;
1116
+ /** Hide the geoman control (use GeoEditor toolbar instead) */
1117
+ hideGeomanControl?: boolean;
1118
+ /** Callback when a feature is created */
1119
+ onFeatureCreate?: (feature: Feature) => void;
1120
+ /** Callback when a feature is edited */
1121
+ onFeatureEdit?: (feature: Feature, oldFeature: Feature) => void;
1122
+ /** Callback when a feature is deleted */
1123
+ onFeatureDelete?: (featureId: string) => void;
1124
+ /** Callback when selection changes */
1125
+ onSelectionChange?: (features: Feature[]) => void;
1126
+ /** Callback when mode changes */
1127
+ onModeChange?: (mode: DrawMode_2 | EditMode_2 | null) => void;
1128
+ /** File modes to enable (default: ['open', 'save']) */
1129
+ fileModes?: FileMode_2[];
1130
+ /** Default filename for saving GeoJSON (default: 'features.geojson') */
1131
+ saveFilename?: string;
1132
+ /** Callback when GeoJSON is loaded */
1133
+ onGeoJsonLoad?: (result: GeoJsonLoadResult_2) => void;
1134
+ /** Callback when GeoJSON is saved */
1135
+ onGeoJsonSave?: (result: GeoJsonSaveResult_2) => void;
1136
+ /** Show feature properties in a popup when selected (default: false) */
1137
+ showFeatureProperties?: boolean;
1138
+ /** Auto-fit map bounds when GeoJSON is loaded (default: true) */
1139
+ fitBoundsOnLoad?: boolean;
1140
+ /** Number of columns for button layout in vertical orientation (default: 1) */
1141
+ columns?: number;
1142
+ }
1143
+
1144
+ declare type GeoEditorOptionsRequired = Required<GeoEditorOptions>;
1145
+
1146
+ /**
1147
+ * React wrapper component for GeoEditor
1148
+ * This component renders nothing but manages the GeoEditor lifecycle
1149
+ */
1150
+ export declare function GeoEditorReact({ map, geoman, position, ...options }: GeoEditorReactProps): null;
1151
+
1152
+ export declare interface GeoEditorReactProps extends GeoEditorOptions_2 {
1153
+ /** MapLibre map instance */
1154
+ map: Map_2;
1155
+ /** Geoman instance for integration */
1156
+ geoman?: GeomanInstance_2;
1157
+ }
1158
+
1159
+ export declare interface GeoEditorState {
1160
+ /** Currently active draw mode */
1161
+ activeDrawMode: DrawMode | null;
1162
+ /** Currently active edit mode */
1163
+ activeEditMode: EditMode | null;
1164
+ /** Currently selected features */
1165
+ selectedFeatures: SelectedFeature[];
1166
+ /** Whether currently drawing */
1167
+ isDrawing: boolean;
1168
+ /** Whether currently editing */
1169
+ isEditing: boolean;
1170
+ /** Features in clipboard for copy/paste */
1171
+ clipboard: Feature[];
1172
+ /** Whether toolbar is collapsed */
1173
+ collapsed: boolean;
1174
+ }
1175
+
1176
+ declare interface GeoEditorState_2 {
1177
+ /** Currently active draw mode */
1178
+ activeDrawMode: DrawMode_2 | null;
1179
+ /** Currently active edit mode */
1180
+ activeEditMode: EditMode_2 | null;
1181
+ /** Currently selected features */
1182
+ selectedFeatures: SelectedFeature_2[];
1183
+ /** Whether currently drawing */
1184
+ isDrawing: boolean;
1185
+ /** Whether currently editing */
1186
+ isEditing: boolean;
1187
+ /** Features in clipboard for copy/paste */
1188
+ clipboard: Feature[];
1189
+ /** Whether toolbar is collapsed */
1190
+ collapsed: boolean;
1191
+ }
1192
+
1193
+ export declare interface GeoJsonLoadResult {
1194
+ /** Successfully loaded features */
1195
+ features: Feature[];
1196
+ /** Number of features loaded */
1197
+ count: number;
1198
+ /** Original filename */
1199
+ filename: string;
1200
+ }
1201
+
1202
+ declare interface GeoJsonLoadResult_2 {
1203
+ /** Successfully loaded features */
1204
+ features: Feature[];
1205
+ /** Number of features loaded */
1206
+ count: number;
1207
+ /** Original filename */
1208
+ filename: string;
1209
+ }
1210
+
1211
+ export declare interface GeoJsonSaveResult {
1212
+ /** The saved FeatureCollection */
1213
+ featureCollection: FeatureCollection;
1214
+ /** Number of features saved */
1215
+ count: number;
1216
+ /** Filename used for download */
1217
+ filename: string;
1218
+ }
1219
+
1220
+ declare interface GeoJsonSaveResult_2 {
1221
+ /** The saved FeatureCollection */
1222
+ featureCollection: FeatureCollection;
1223
+ /** Number of features saved */
1224
+ count: number;
1225
+ /** Filename used for download */
1226
+ filename: string;
1227
+ }
1228
+
1229
+ declare interface GeomanEventParameters {
1230
+ type: string;
1231
+ feature?: Feature;
1232
+ shape?: string;
1233
+ [key: string]: any;
1234
+ }
1235
+
1236
+ declare interface GeomanEventParameters_2 {
1237
+ type: string;
1238
+ feature?: Feature;
1239
+ shape?: string;
1240
+ [key: string]: any;
1241
+ }
1242
+
1243
+ declare interface GeomanFeatureData {
1244
+ id: string | number;
1245
+ shape: string;
1246
+ geoJson?: Feature;
1247
+ getGeoJson?: () => Feature;
1248
+ updateGeometry?: (geometry: Geometry) => void;
1249
+ updateGeoJsonGeometry?: (geometry: Geometry) => void;
1250
+ temporary?: boolean;
1251
+ delete: () => void;
1252
+ }
1253
+
1254
+ declare interface GeomanFeatureData_2 {
1255
+ id: string | number;
1256
+ shape: string;
1257
+ geoJson?: Feature;
1258
+ getGeoJson?: () => Feature;
1259
+ updateGeometry?: (geometry: Geometry) => void;
1260
+ updateGeoJsonGeometry?: (geometry: Geometry) => void;
1261
+ temporary?: boolean;
1262
+ delete: () => void;
1263
+ }
1264
+
1265
+ export declare interface GeomanFeaturesAPI {
1266
+ getAll: () => FeatureCollection;
1267
+ get: (sourceName: string, featureId: string) => GeomanFeatureData_2 | null;
1268
+ forEach: (callback: (feature: GeomanFeatureData_2) => void) => void;
1269
+ tmpForEach?: (callback: (feature: GeomanFeatureData_2) => void) => void;
1270
+ has: (sourceName: string, featureId: string) => boolean;
1271
+ delete: (featureData: GeomanFeatureData_2) => void;
1272
+ deleteAll: () => void;
1273
+ importGeoJson: (geoJson: FeatureCollection, options?: {
1274
+ overwrite?: boolean;
1275
+ }) => {
1276
+ success: number;
1277
+ failed: number;
1278
+ };
1279
+ importGeoJsonFeature: (feature: Feature) => GeomanFeatureData_2 | null;
1280
+ getFeatureByMouseEvent: (options: {
1281
+ event: MapMouseEvent | MapTouchEvent;
1282
+ sourceNames?: string[];
1283
+ }) => GeomanFeatureData_2 | null;
1284
+ getFeaturesByScreenBounds: (options: {
1285
+ bounds: [[number, number], [number, number]];
1286
+ sourceNames?: string[];
1287
+ }) => GeomanFeatureData_2[];
1288
+ }
1289
+
1290
+ declare interface GeomanFeaturesAPI_2 {
1291
+ getAll: () => FeatureCollection;
1292
+ get: (sourceName: string, featureId: string) => GeomanFeatureData | null;
1293
+ forEach: (callback: (feature: GeomanFeatureData) => void) => void;
1294
+ tmpForEach?: (callback: (feature: GeomanFeatureData) => void) => void;
1295
+ has: (sourceName: string, featureId: string) => boolean;
1296
+ delete: (featureData: GeomanFeatureData) => void;
1297
+ deleteAll: () => void;
1298
+ importGeoJson: (geoJson: FeatureCollection, options?: {
1299
+ overwrite?: boolean;
1300
+ }) => {
1301
+ success: number;
1302
+ failed: number;
1303
+ };
1304
+ importGeoJsonFeature: (feature: Feature) => GeomanFeatureData | null;
1305
+ getFeatureByMouseEvent: (options: {
1306
+ event: MapMouseEvent | MapTouchEvent;
1307
+ sourceNames?: string[];
1308
+ }) => GeomanFeatureData | null;
1309
+ getFeaturesByScreenBounds: (options: {
1310
+ bounds: [[number, number], [number, number]];
1311
+ sourceNames?: string[];
1312
+ }) => GeomanFeatureData[];
1313
+ }
1314
+
1315
+ export declare interface GeomanInstance {
1316
+ enableDraw: (shape: DrawMode) => void;
1317
+ disableDraw: () => void;
1318
+ toggleDraw: (shape: DrawMode) => void;
1319
+ drawEnabled: (shape?: DrawMode) => boolean;
1320
+ enableMode: (modeType: 'draw' | 'edit' | 'helper', mode: string) => void;
1321
+ disableMode: (modeType: 'draw' | 'edit' | 'helper', mode: string) => void;
1322
+ toggleMode: (modeType: 'draw' | 'edit' | 'helper', mode: string) => void;
1323
+ isModeEnabled: (modeType: 'draw' | 'edit' | 'helper', mode: string) => boolean;
1324
+ enableGlobalEditMode: () => void;
1325
+ disableGlobalEditMode: () => void;
1326
+ toggleGlobalEditMode: () => void;
1327
+ globalEditModeEnabled: () => boolean;
1328
+ enableGlobalDragMode: () => void;
1329
+ disableGlobalDragMode: () => void;
1330
+ toggleGlobalDragMode: () => void;
1331
+ globalDragModeEnabled: () => boolean;
1332
+ enableGlobalRotateMode: () => void;
1333
+ disableGlobalRotateMode: () => void;
1334
+ toggleGlobalRotateMode: () => void;
1335
+ globalRotateModeEnabled: () => boolean;
1336
+ enableGlobalCutMode: () => void;
1337
+ disableGlobalCutMode: () => void;
1338
+ toggleGlobalCutMode: () => void;
1339
+ globalCutModeEnabled: () => boolean;
1340
+ enableGlobalRemovalMode: () => void;
1341
+ disableGlobalRemovalMode: () => void;
1342
+ toggleGlobalRemovalMode: () => void;
1343
+ globalRemovalModeEnabled: () => boolean;
1344
+ disableAllModes: () => void;
1345
+ addControls: (controlsElement?: HTMLElement) => Promise<void>;
1346
+ removeControls: () => void;
1347
+ setGlobalEventsListener: (callback?: (parameters: GeomanEventParameters_2) => void) => void;
1348
+ features: GeomanFeaturesAPI;
1349
+ }
1350
+
1351
+ declare interface GeomanInstance_2 {
1352
+ enableDraw: (shape: DrawMode_2) => void;
1353
+ disableDraw: () => void;
1354
+ toggleDraw: (shape: DrawMode_2) => void;
1355
+ drawEnabled: (shape?: DrawMode_2) => boolean;
1356
+ enableMode: (modeType: 'draw' | 'edit' | 'helper', mode: string) => void;
1357
+ disableMode: (modeType: 'draw' | 'edit' | 'helper', mode: string) => void;
1358
+ toggleMode: (modeType: 'draw' | 'edit' | 'helper', mode: string) => void;
1359
+ isModeEnabled: (modeType: 'draw' | 'edit' | 'helper', mode: string) => boolean;
1360
+ enableGlobalEditMode: () => void;
1361
+ disableGlobalEditMode: () => void;
1362
+ toggleGlobalEditMode: () => void;
1363
+ globalEditModeEnabled: () => boolean;
1364
+ enableGlobalDragMode: () => void;
1365
+ disableGlobalDragMode: () => void;
1366
+ toggleGlobalDragMode: () => void;
1367
+ globalDragModeEnabled: () => boolean;
1368
+ enableGlobalRotateMode: () => void;
1369
+ disableGlobalRotateMode: () => void;
1370
+ toggleGlobalRotateMode: () => void;
1371
+ globalRotateModeEnabled: () => boolean;
1372
+ enableGlobalCutMode: () => void;
1373
+ disableGlobalCutMode: () => void;
1374
+ toggleGlobalCutMode: () => void;
1375
+ globalCutModeEnabled: () => boolean;
1376
+ enableGlobalRemovalMode: () => void;
1377
+ disableGlobalRemovalMode: () => void;
1378
+ toggleGlobalRemovalMode: () => void;
1379
+ globalRemovalModeEnabled: () => boolean;
1380
+ disableAllModes: () => void;
1381
+ addControls: (controlsElement?: HTMLElement) => Promise<void>;
1382
+ removeControls: () => void;
1383
+ setGlobalEventsListener: (callback?: (parameters: GeomanEventParameters) => void) => void;
1384
+ features: GeomanFeaturesAPI_2;
1385
+ }
1386
+
1387
+ /**
1388
+ * Get bounding box of a feature
1389
+ */
1390
+ export declare function getBBox(feature: Feature): [number, number, number, number];
1391
+
1392
+ /**
1393
+ * Get the bounding box center of a feature
1394
+ */
1395
+ export declare function getBBoxCenter(feature: Feature): Position;
1396
+
1397
+ /**
1398
+ * Get the bounding box corners as coordinates
1399
+ */
1400
+ export declare function getBBoxCorners(feature: Feature): Position[];
1401
+
1402
+ /**
1403
+ * Get the midpoints of the bounding box edges
1404
+ */
1405
+ export declare function getBBoxMidpoints(feature: Feature): Position[];
1406
+
1407
+ /**
1408
+ * Get the center point of a feature
1409
+ */
1410
+ export declare function getCenter(feature: Feature): Position;
1411
+
1412
+ /**
1413
+ * Get all coordinates from a feature
1414
+ */
1415
+ export declare function getCoordAll(feature: Feature): Position[];
1416
+
1417
+ /**
1418
+ * Get the feature ID, generating one if it doesn't exist
1419
+ */
1420
+ export declare function getFeatureId(feature: Feature): string;
1421
+
1422
+ /**
1423
+ * Get only polygon features from a collection
1424
+ */
1425
+ export declare function getPolygonFeatures(features: Feature[]): Feature<Polygon>[];
1426
+
1427
+ /**
1428
+ * Get vertex count of a feature
1429
+ */
1430
+ export declare function getVertexCount(feature: Feature): number;
1431
+
1432
+ export declare type HelperMode = 'snapping' | 'measurements';
1433
+
1434
+ declare type HelperMode_2 = 'snapping' | 'measurements';
1435
+
1436
+ /**
1437
+ * Check if two features intersect
1438
+ */
1439
+ export declare function intersects(feature1: Feature, feature2: Feature): boolean;
1440
+
1441
+ /**
1442
+ * Check if a feature is in the selection
1443
+ */
1444
+ export declare function isFeatureSelected(feature: Feature, selection: SelectedFeature[]): boolean;
1445
+
1446
+ /**
1447
+ * Check if a feature is a line
1448
+ */
1449
+ export declare function isLine(feature: Feature): feature is Feature<LineString>;
1450
+
1451
+ /**
1452
+ * Check if a feature is a point
1453
+ */
1454
+ export declare function isPoint(feature: Feature): feature is Feature<Point>;
1455
+
1456
+ /**
1457
+ * Check if a feature is a polygon
1458
+ */
1459
+ export declare function isPolygon(feature: Feature): feature is Feature<Polygon>;
1460
+
1461
+ /**
1462
+ * Check if selection contains only polygons
1463
+ */
1464
+ export declare function isPolygonOnlySelection(features: Feature[]): boolean;
1465
+
1466
+ /**
1467
+ * Check if a feature has a valid geometry
1468
+ */
1469
+ export declare function isValidGeometry(feature: Feature): boolean;
1470
+
1471
+ /**
1472
+ * Check if a feature is within another feature
1473
+ */
1474
+ export declare function isWithin(feature: Feature, container: Feature): boolean;
1475
+
1476
+ /**
1477
+ * Handles lasso selection of features
1478
+ */
1479
+ export declare class LassoFeature {
1480
+ private map;
1481
+ private isDrawing;
1482
+ private points;
1483
+ private options;
1484
+ private onCompleteCallback;
1485
+ private dragPanEnabled;
1486
+ private boxZoomEnabled;
1487
+ private doubleClickZoomEnabled;
1488
+ private handleMouseDown;
1489
+ private handleMouseMove;
1490
+ private handleMouseUp;
1491
+ constructor(options?: LassoOptions);
1492
+ /**
1493
+ * Initialize with map instance
1494
+ */
1495
+ init(map: Map_2): void;
1496
+ /**
1497
+ * Enable lasso selection mode
1498
+ */
1499
+ enable(onComplete?: (result: LassoResult) => void): void;
1500
+ /**
1501
+ * Disable lasso selection mode
1502
+ */
1503
+ disable(): void;
1504
+ /**
1505
+ * Get features within the lasso polygon
1506
+ */
1507
+ selectWithinLasso(lassoPolygon: Feature<Polygon>, features: Feature[]): Feature[];
1508
+ /**
1509
+ * Build polygon from drawn points
1510
+ */
1511
+ buildLassoPolygon(): Feature<Polygon> | null;
1512
+ /**
1513
+ * Set selection mode
1514
+ */
1515
+ setMode(mode: 'contains' | 'intersects'): void;
1516
+ /**
1517
+ * Check if lasso is currently active
1518
+ */
1519
+ isActive(): boolean;
1520
+ /**
1521
+ * Setup map layers for lasso visualization
1522
+ */
1523
+ private setupLassoLayers;
1524
+ /**
1525
+ * Attach mouse event listeners
1526
+ */
1527
+ private attachEventListeners;
1528
+ /**
1529
+ * Remove event listeners
1530
+ */
1531
+ private removeEventListeners;
1532
+ /**
1533
+ * Update the lasso visualization on the map
1534
+ */
1535
+ private updateLassoVisualization;
1536
+ /**
1537
+ * Complete the lasso selection
1538
+ */
1539
+ private completeLasso;
1540
+ /**
1541
+ * Clear the lasso visualization
1542
+ */
1543
+ private clearLasso;
1544
+ private disableMapInteractions;
1545
+ private restoreMapInteractions;
1546
+ /**
1547
+ * Remove lasso layers from the map
1548
+ */
1549
+ removeLayers(): void;
1550
+ /**
1551
+ * Cleanup resources
1552
+ */
1553
+ destroy(): void;
1554
+ }
1555
+
1556
+ export declare interface LassoOptions {
1557
+ /** Selection mode: 'contains' or 'intersects' */
1558
+ mode?: 'contains' | 'intersects';
1559
+ }
1560
+
1561
+ export declare interface LassoResult {
1562
+ /** Features selected by the lasso */
1563
+ selected: Feature[];
1564
+ /** The lasso polygon used for selection */
1565
+ lasso: Feature<Polygon>;
1566
+ }
1567
+
1568
+ /**
1569
+ * Check if two polygons overlap
1570
+ */
1571
+ export declare function overlaps(feature1: Feature<Polygon | MultiPolygon>, feature2: Feature<Polygon | MultiPolygon>): boolean;
1572
+
1573
+ /**
1574
+ * Convert polygon to line
1575
+ */
1576
+ export declare function polygonToLine(polygon: Feature<Polygon | MultiPolygon>): ReturnType<typeof turf.polygonToLine>;
1577
+
1578
+ /**
1579
+ * Check if two positions are approximately equal
1580
+ */
1581
+ export declare function positionsEqual(pos1: Position, pos2: Position, tolerance?: number): boolean;
1582
+
1583
+ /**
1584
+ * Convert radians to degrees
1585
+ */
1586
+ export declare function radiansToDegrees(radians: number): number;
1587
+
1588
+ /**
1589
+ * Remove feature from selection
1590
+ */
1591
+ export declare function removeFromSelection(selection: SelectedFeature[], featureId: string): SelectedFeature[];
1592
+
1593
+ /**
1594
+ * Round coordinates to a specified precision
1595
+ */
1596
+ export declare function roundCoordinates(coordinates: Position, precision?: number): Position;
1597
+
1598
+ /**
1599
+ * Get centroid with fallback for invalid geometries
1600
+ */
1601
+ export declare function safeCentroid(feature: Feature): Feature<Point>;
1602
+
1603
+ /**
1604
+ * Safe wrapper for turf.clone
1605
+ */
1606
+ export declare function safeClone<T extends Feature>(feature: T): T;
1607
+
1608
+ /**
1609
+ * Safe wrapper for turf.difference
1610
+ */
1611
+ export declare function safeDifference(polygon1: Feature<Polygon | MultiPolygon>, polygon2: Feature<Polygon | MultiPolygon>): Feature<Polygon | MultiPolygon> | null;
1612
+
1613
+ /**
1614
+ * Safe wrapper for turf.lineIntersect
1615
+ */
1616
+ export declare function safeLineIntersect(line1: Feature<LineString>, line2: Feature<LineString>): FeatureCollection<Point>;
1617
+
1618
+ /**
1619
+ * Safe wrapper for turf.lineSplit
1620
+ */
1621
+ export declare function safeLineSplit(line: Feature<LineString>, splitter: Feature<LineString>): FeatureCollection<LineString>;
1622
+
1623
+ /**
1624
+ * Safe wrapper for turf.transformScale
1625
+ */
1626
+ export declare function safeScale(feature: Feature, factor: number, origin?: Position): Feature;
1627
+
1628
+ /**
1629
+ * Safe wrapper for turf.simplify
1630
+ */
1631
+ export declare function safeSimplify<T extends Feature>(feature: T, options: {
1632
+ tolerance: number;
1633
+ highQuality?: boolean;
1634
+ }): T;
1635
+
1636
+ /**
1637
+ * Safe wrapper for turf.transformTranslate
1638
+ */
1639
+ export declare function safeTranslate(feature: Feature, distance: number, direction: number): Feature;
1640
+
1641
+ /**
1642
+ * Safe wrapper for turf.union that handles edge cases
1643
+ */
1644
+ export declare function safeUnion(features: Feature<Polygon | MultiPolygon>[]): Feature<Polygon | MultiPolygon> | null;
1645
+
1646
+ /**
1647
+ * Handles interactive scaling of features
1648
+ */
1649
+ export declare class ScaleFeature {
1650
+ private map;
1651
+ private options;
1652
+ private activeFeature;
1653
+ private originalFeature;
1654
+ private handles;
1655
+ private activeHandle;
1656
+ private startPoint;
1657
+ private onScaleCallback;
1658
+ constructor(options?: ScaleOptions);
1659
+ /**
1660
+ * Initialize with map instance
1661
+ */
1662
+ init(map: Map_2): void;
1663
+ /**
1664
+ * Scale a feature by a given factor
1665
+ */
1666
+ scale(feature: Feature, factor: number, origin?: Position): Feature;
1667
+ /**
1668
+ * Scale feature by dragging from a specific handle
1669
+ */
1670
+ scaleFromHandle(feature: Feature, handlePosition: ScaleHandlePosition, startPoint: Position, currentPoint: Position): Feature;
1671
+ /**
1672
+ * Create scale handles for a feature
1673
+ */
1674
+ createHandles(feature: Feature): ScaleHandle[];
1675
+ /**
1676
+ * Start scaling operation
1677
+ */
1678
+ startScale(feature: Feature, handlePosition: ScaleHandlePosition, startPoint: Position, onScale?: (feature: Feature, factor: number) => void): void;
1679
+ /**
1680
+ * Show scale handles without starting a drag operation
1681
+ */
1682
+ showHandlesForFeature(feature: Feature): void;
1683
+ /**
1684
+ * Update scaling during drag
1685
+ */
1686
+ updateScale(currentPoint: Position): Feature | null;
1687
+ /**
1688
+ * End scaling operation
1689
+ */
1690
+ endScale(): {
1691
+ feature: Feature;
1692
+ factor: number;
1693
+ } | null;
1694
+ /**
1695
+ * Cancel scaling operation
1696
+ */
1697
+ cancelScale(): void;
1698
+ /**
1699
+ * Show scale handles on the map
1700
+ */
1701
+ private showHandles;
1702
+ /**
1703
+ * Update handle positions after scaling
1704
+ */
1705
+ private updateHandlePositions;
1706
+ /**
1707
+ * Hide scale handles from the map
1708
+ */
1709
+ private hideHandles;
1710
+ /**
1711
+ * Calculate distance from a point to the center
1712
+ */
1713
+ private distanceFromCenter;
1714
+ /**
1715
+ * Get the opposite corner for scaling origin
1716
+ */
1717
+ private getOppositeCorner;
1718
+ /**
1719
+ * Get handle at a specific point
1720
+ */
1721
+ getHandleAtPoint(point: Position, tolerance?: number): ScaleHandlePosition | null;
1722
+ /**
1723
+ * Cleanup resources
1724
+ */
1725
+ destroy(): void;
1726
+ }
1727
+
1728
+ export declare interface ScaleHandle {
1729
+ position: ScaleHandlePosition;
1730
+ coordinates: [number, number];
1731
+ }
1732
+
1733
+ export declare type ScaleHandlePosition = 'nw' | 'n' | 'ne' | 'e' | 'se' | 's' | 'sw' | 'w';
1734
+
1735
+ export declare interface ScaleOptions {
1736
+ /** Maintain aspect ratio during scaling */
1737
+ maintainAspectRatio?: boolean;
1738
+ /** Scale from center of feature */
1739
+ scaleFromCenter?: boolean;
1740
+ /** Minimum scale factor */
1741
+ minScale?: number;
1742
+ /** Maximum scale factor */
1743
+ maxScale?: number;
1744
+ }
1745
+
1746
+ export declare interface SelectedFeature {
1747
+ id: string;
1748
+ feature: Feature;
1749
+ layerId: string;
1750
+ /** Reference to geoman feature data for deletion */
1751
+ geomanData?: GeomanFeatureData_2;
1752
+ }
1753
+
1754
+ declare interface SelectedFeature_2 {
1755
+ id: string;
1756
+ feature: Feature;
1757
+ layerId: string;
1758
+ /** Reference to geoman feature data for deletion */
1759
+ geomanData?: GeomanFeatureData;
1760
+ }
1761
+
1762
+ /**
1763
+ * Filter features that are within a lasso polygon
1764
+ */
1765
+ export declare function selectFeaturesWithinLasso(features: Feature[], lasso: Feature<Polygon>, mode?: 'contains' | 'intersects'): Feature[];
1766
+
1767
+ /**
1768
+ * Handles line/polygon simplification using Douglas-Peucker algorithm
1769
+ */
1770
+ export declare class SimplifyFeature {
1771
+ private defaultOptions;
1772
+ constructor(options?: Partial<SimplifyOptions>);
1773
+ /**
1774
+ * Simplify a geometry using Douglas-Peucker algorithm
1775
+ */
1776
+ simplify<T extends Feature>(feature: T, options?: Partial<SimplifyOptions>): T;
1777
+ /**
1778
+ * Simplify and return detailed result with statistics
1779
+ */
1780
+ simplifyWithStats(feature: Feature, options?: Partial<SimplifyOptions>): SimplifyResult;
1781
+ /**
1782
+ * Get simplification statistics without applying
1783
+ */
1784
+ getSimplificationStats(feature: Feature, tolerance: number): {
1785
+ before: number;
1786
+ after: number;
1787
+ reduction: number;
1788
+ };
1789
+ /**
1790
+ * Preview simplification at different tolerance levels
1791
+ */
1792
+ previewTolerances(feature: Feature, tolerances: number[]): Map<number, SimplifyResult>;
1793
+ /**
1794
+ * Get suggested tolerance values based on feature complexity
1795
+ */
1796
+ getSuggestedTolerances(feature: Feature): number[];
1797
+ /**
1798
+ * Find optimal tolerance for a target vertex reduction
1799
+ */
1800
+ findOptimalTolerance(feature: Feature, targetReduction: number): {
1801
+ tolerance: number;
1802
+ result: SimplifyResult;
1803
+ };
1804
+ /**
1805
+ * Set default tolerance
1806
+ */
1807
+ setDefaultTolerance(tolerance: number): void;
1808
+ /**
1809
+ * Get default tolerance
1810
+ */
1811
+ getDefaultTolerance(): number;
1812
+ }
1813
+
1814
+ export declare interface SimplifyOptions {
1815
+ /** Tolerance for simplification (in degrees) */
1816
+ tolerance: number;
1817
+ /** Use high quality simplification */
1818
+ highQuality?: boolean;
1819
+ /** Mutate original feature */
1820
+ mutate?: boolean;
1821
+ }
1822
+
1823
+ export declare interface SimplifyResult {
1824
+ /** Simplified feature */
1825
+ result: Feature;
1826
+ /** Original feature */
1827
+ original: Feature;
1828
+ /** Number of vertices before */
1829
+ verticesBefore: number;
1830
+ /** Number of vertices after */
1831
+ verticesAfter: number;
1832
+ /** Reduction percentage */
1833
+ reductionPercent: number;
1834
+ }
1835
+
1836
+ /**
1837
+ * Handles splitting of polygons and lines
1838
+ */
1839
+ export declare class SplitFeature {
1840
+ private map;
1841
+ private isDrawing;
1842
+ private splitLinePoints;
1843
+ private targetFeature;
1844
+ private onCompleteCallback;
1845
+ private handleClick;
1846
+ private handleMouseMove;
1847
+ private handleDblClick;
1848
+ constructor();
1849
+ /**
1850
+ * Initialize with map instance
1851
+ */
1852
+ init(map: Map_2): void;
1853
+ /**
1854
+ * Split a polygon with a line
1855
+ */
1856
+ splitPolygon(polygon: Feature<Polygon>, splitter: Feature<LineString>, _options?: SplitOptions): SplitResult;
1857
+ /**
1858
+ * Split a line with a point or another line
1859
+ */
1860
+ splitLine(line: Feature<LineString>, splitter: Feature<LineString>): SplitResult;
1861
+ /**
1862
+ * Start interactive split mode
1863
+ */
1864
+ startSplit(feature: Feature<Polygon | LineString>, onComplete: (result: SplitResult) => void): void;
1865
+ /**
1866
+ * Cancel the split operation
1867
+ */
1868
+ cancelSplit(): void;
1869
+ /**
1870
+ * Check if split mode is active
1871
+ */
1872
+ isActive(): boolean;
1873
+ /**
1874
+ * Perform the actual polygon split
1875
+ */
1876
+ private performPolygonSplit;
1877
+ /**
1878
+ * Clip a line to a bounding box
1879
+ */
1880
+ private clipLineToBbox;
1881
+ /**
1882
+ * Setup layers for split line visualization
1883
+ */
1884
+ private setupSplitLineLayers;
1885
+ /**
1886
+ * Attach event listeners for drawing the split line
1887
+ */
1888
+ private attachEventListeners;
1889
+ /**
1890
+ * Remove event listeners
1891
+ */
1892
+ private removeEventListeners;
1893
+ /**
1894
+ * Update the split line visualization
1895
+ */
1896
+ private updateSplitLineVisualization;
1897
+ /**
1898
+ * Complete the split operation
1899
+ */
1900
+ private completeSplit;
1901
+ /**
1902
+ * Cleanup after split operation
1903
+ */
1904
+ private cleanup;
1905
+ /**
1906
+ * Clear the split line visualization
1907
+ */
1908
+ private clearSplitLine;
1909
+ /**
1910
+ * Remove split line layers from the map
1911
+ */
1912
+ removeLayers(): void;
1913
+ /**
1914
+ * Cleanup resources
1915
+ */
1916
+ destroy(): void;
1917
+ }
1918
+
1919
+ export declare interface SplitOptions {
1920
+ /** Keep the original feature after splitting */
1921
+ keepOriginal?: boolean;
1922
+ }
1923
+
1924
+ export declare interface SplitResult {
1925
+ /** Original feature that was split */
1926
+ original: Feature<Polygon | LineString>;
1927
+ /** Resulting parts after splitting */
1928
+ parts: Feature[];
1929
+ /** Whether the operation was successful */
1930
+ success: boolean;
1931
+ /** Error message if operation failed */
1932
+ error?: string;
1933
+ }
1934
+
1935
+ /**
1936
+ * Toggle feature in selection
1937
+ */
1938
+ export declare function toggleInSelection(selection: SelectedFeature[], feature: Feature, layerId?: string): SelectedFeature[];
1939
+
1940
+ export declare type ToolbarOrientation = 'vertical' | 'horizontal';
1941
+
1942
+ declare type ToolbarOrientation_2 = 'vertical' | 'horizontal';
1943
+
1944
+ export declare type ToolbarPosition = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
1945
+
1946
+ declare type ToolbarPosition_2 = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
1947
+
1948
+ /**
1949
+ * Convert Feature array to SelectedFeature array
1950
+ */
1951
+ export declare function toSelectedFeatures(features: Feature[], layerId?: string): SelectedFeature[];
1952
+
1953
+ /**
1954
+ * Handles polygon union/merge operations
1955
+ */
1956
+ export declare class UnionFeature {
1957
+ /**
1958
+ * Merge multiple polygons into one
1959
+ */
1960
+ union(features: Feature<Polygon | MultiPolygon>[], options?: UnionOptions): UnionResult;
1961
+ /**
1962
+ * Check if polygons can be merged
1963
+ */
1964
+ canMerge(features: Feature<Polygon | MultiPolygon>[]): {
1965
+ canMerge: boolean;
1966
+ reason?: string;
1967
+ };
1968
+ /**
1969
+ * Check if any polygons overlap
1970
+ */
1971
+ hasOverlap(features: Feature<Polygon | MultiPolygon>[]): boolean;
1972
+ /**
1973
+ * Get the combined area of all polygons
1974
+ */
1975
+ getCombinedArea(features: Feature<Polygon | MultiPolygon>[]): number;
1976
+ /**
1977
+ * Get the area of the union result
1978
+ */
1979
+ getUnionArea(features: Feature<Polygon | MultiPolygon>[]): number | null;
1980
+ }
1981
+
1982
+ export declare interface UnionOptions {
1983
+ /** Properties to use for the merged feature */
1984
+ properties?: GeoJsonProperties;
1985
+ }
1986
+
1987
+ export declare interface UnionResult {
1988
+ /** Resulting merged feature */
1989
+ result: Feature<Polygon | MultiPolygon> | null;
1990
+ /** Original features that were merged */
1991
+ originals: Feature<Polygon | MultiPolygon>[];
1992
+ /** Whether the operation was successful */
1993
+ success: boolean;
1994
+ /** Error message if operation failed */
1995
+ error?: string;
1996
+ }
1997
+
1998
+ /**
1999
+ * Hook for using GeoEditor imperatively
2000
+ */
2001
+ export declare function useGeoEditor(map: Map_2 | null, options?: GeoEditorOptions_2): {
2002
+ control: GeoEditor_2 | null;
2003
+ enableDrawMode: (mode: DrawMode_2) => void;
2004
+ enableEditMode: (mode: EditMode_2) => void;
2005
+ disableAllModes: () => void;
2006
+ copySelected: () => void;
2007
+ pasteFeatures: () => void;
2008
+ deleteSelected: () => void;
2009
+ clearSelection: () => void;
2010
+ openFileDialog: () => void;
2011
+ loadGeoJson: (geoJson: FeatureCollection | Feature, filename?: string) => GeoJsonLoadResult_2 | undefined;
2012
+ saveGeoJson: (filename?: string) => GeoJsonSaveResult_2 | undefined;
2013
+ };
2014
+
1
2015
  export { }