-
Notifications
You must be signed in to change notification settings - Fork 433
/
leaflet-geoman.d.ts
1577 lines (1283 loc) · 49 KB
/
leaflet-geoman.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import * as L from 'leaflet';
// redeclare module, maintains compatibility with @types/leaflet
declare module 'leaflet' {
/**
* Extends built in leaflet Layer Options.
*/
interface LayerOptions {
pmIgnore?: boolean;
snapIgnore?: boolean;
}
/**
* Extends built in leaflet Map Options.
*/
interface MapOptions {
pmIgnore?: boolean;
}
/**
* Extends built in leaflet Map.
*/
interface Map {
pm: PM.PMMap;
}
/**
* Extends built in leaflet Path.
*/
interface Path {
pm: PM.PMLayer;
}
/**
* Extends built in leaflet ImageOverlay.
*/
interface ImageOverlay {
pm: PM.PMLayer;
}
/**
* Extends built in leaflet LayerGroup.
*/
interface LayerGroup {
pm: PM.PMLayerGroup;
}
/**
* Extends built in leaflet MarkerOptions with options for Text-Layer
*/
interface MarkerOptions {
textMarker?: boolean;
text?: string;
}
/**
* Extends built in leaflet Marker.
*/
interface Marker {
pm: PM.PMLayer;
}
/**
* Extends @types/leaflet events...
*
* Todo: This is kind of a mess, and it makes all these event handlers show
* up on Layers and Map. Leaflet itself is based around Evented, and @types/leaflet
* makes this very hard to work around.
*
*/
interface Evented {
/******************************************
*
* AVAILABLE ON MAP + LAYER, THESE ARE OK ON EVENTED.
*
********************************************/
/** Fired when a layer is removed via Removal Mode. */
on(type: 'pm:remove', fn: PM.RemoveEventHandler): this;
once(type: 'pm:remove', fn: PM.RemoveEventHandler): this;
off(type: 'pm:remove', fn?: PM.RemoveEventHandler): this;
/** Fired when the layer being cut. Draw+Edit Mode*/
on(type: 'pm:cut', fn: PM.CutEventHandler): this;
once(type: 'pm:cut', fn: PM.CutEventHandler): this;
off(type: 'pm:cut', fn?: PM.CutEventHandler): this;
/** Fired when rotation is enabled for a layer. */
on(type: 'pm:rotateenable', fn: PM.RotateEnableEventHandler): this;
once(type: 'pm:rotateenable', fn: PM.RotateEnableEventHandler): this;
off(type: 'pm:rotateenable', fn?: PM.RotateEnableEventHandler): this;
/** Fired when rotation is disabled for a layer. */
on(type: 'pm:rotatedisable', fn: PM.RotateDisableEventHandler): this;
once(type: 'pm:rotatedisable', fn: PM.RotateDisableEventHandler): this;
off(type: 'pm:rotatedisable', fn?: PM.RotateDisableEventHandler): this;
/** Fired when rotation starts on a layer. */
on(type: 'pm:rotatestart', fn: PM.RotateStartEventHandler): this;
once(type: 'pm:rotatestart', fn: PM.RotateStartEventHandler): this;
off(type: 'pm:rotatestart', fn?: PM.RotateStartEventHandler): this;
/** Fired when a layer is rotated. */
on(type: 'pm:rotate', fn: PM.RotateEventHandler): this;
once(type: 'pm:rotate', fn: PM.RotateEventHandler): this;
off(type: 'pm:rotate', fn?: PM.RotateEventHandler): this;
/** Fired when rotation ends on a layer. */
on(type: 'pm:rotateend', fn: PM.RotateEndEventHandler): this;
once(type: 'pm:rotateend', fn: PM.RotateEndEventHandler): this;
off(type: 'pm:rotateend', fn?: PM.RotateEndEventHandler): this;
/******************************************
*
* TODO: DRAW/EDIT MODE EVENTS LAYER ONLY
*
********************************************/
/** Fired during a marker move/drag. */
on(type: 'pm:snapdrag', fn: PM.SnapEventHandler): this;
once(type: 'pm:snapdrag', fn: PM.SnapEventHandler): this;
off(type: 'pm:snapdrag', fn?: PM.SnapEventHandler): this;
/** Fired when a vertex is snapped. */
on(type: 'pm:snap', fn: PM.SnapEventHandler): this;
once(type: 'pm:snap', fn: PM.SnapEventHandler): this;
off(type: 'pm:snap', fn?: PM.SnapEventHandler): this;
/** Fired when a vertex is unsnapped. */
on(type: 'pm:unsnap', fn: PM.SnapEventHandler): this;
once(type: 'pm:unsnap', fn: PM.SnapEventHandler): this;
off(type: 'pm:unsnap', fn?: PM.SnapEventHandler): this;
/** Called when the center of a circle is placed/moved. */
on(type: 'pm:centerplaced', fn: PM.CenterPlacedEventHandler): this;
once(type: 'pm:centerplaced', fn: PM.CenterPlacedEventHandler): this;
off(type: 'pm:centerplaced', fn?: PM.CenterPlacedEventHandler): this;
/******************************************
*
* TODO: CUT/EDIT MODE EVENTS LAYER ONLY
*
********************************************/
/** Fired when a layer is edited. */
on(type: 'pm:edit', fn: PM.EditEventHandler): this;
once(type: 'pm:edit', fn: PM.EditEventHandler): this;
off(type: 'pm:edit', fn?: PM.EditEventHandler): this;
/******************************************
*
* TODO: DRAW MODE EVENTS ON MAP ONLY
*
********************************************/
/** Fired when Drawing Mode is toggled. */
on(
type: 'pm:globaldrawmodetoggled',
fn: PM.GlobalDrawModeToggledEventHandler,
context?: any
): L.Evented;
once(
type: 'pm:globaldrawmodetoggled',
fn: PM.GlobalDrawModeToggledEventHandler,
context?: any
): L.Evented;
off(
type: 'pm:globaldrawmodetoggled',
fn?: PM.GlobalDrawModeToggledEventHandler,
context?: any
): L.Evented;
/** Called when drawing mode is enabled. Payload includes the shape type and working layer. */
on(
type: 'pm:drawstart',
fn: PM.DrawStartEventHandler,
context?: any
): L.Evented;
once(
type: 'pm:drawstart',
fn: PM.DrawStartEventHandler,
context?: any
): L.Evented;
off(
type: 'pm:drawstart',
fn?: PM.DrawStartEventHandler,
context?: any
): L.Evented;
/** Called when drawing mode is disabled. Payload includes the shape type. */
on(
type: 'pm:drawend',
fn: PM.DrawEndEventHandler,
context?: any
): L.Evented;
once(
type: 'pm:drawend',
fn: PM.DrawEndEventHandler,
context?: any
): L.Evented;
off(
type: 'pm:drawend',
fn?: PM.DrawEndEventHandler,
context?: any
): L.Evented;
/** Called when drawing mode is disabled. Payload includes the shape type. */
on(type: 'pm:create', fn: PM.CreateEventHandler, context?: any): L.Evented;
once(
type: 'pm:create',
fn: PM.CreateEventHandler,
context?: any
): L.Evented;
off(
type: 'pm:create',
fn?: PM.CreateEventHandler,
context?: any
): L.Evented;
/******************************************
*
* TODO: DRAW MODE EVENTS ON LAYER ONLY
*
********************************************/
/** Called when a new vertex is added. */
on(type: 'pm:vertexadded', fn: PM.VertexAddedEventHandler): this;
once(type: 'pm:vertexadded', fn: PM.VertexAddedEventHandler): this;
off(type: 'pm:vertexadded', fn?: PM.VertexAddedEventHandler): this;
/******************************************
*
* TODO: EDIT MODE EVENTS ON LAYER ONLY
*
********************************************/
/** Fired when edit mode is disabled and a layer is edited and its coordinates have changed. */
on(type: 'pm:update', fn: PM.UpdateEventHandler): this;
once(type: 'pm:update', fn: PM.UpdateEventHandler): this;
off(type: 'pm:update', fn?: PM.UpdateEventHandler): this;
/** Fired when edit mode on a layer is enabled. */
on(type: 'pm:enable', fn: PM.EnableEventHandler): this;
once(type: 'pm:enable', fn: PM.EnableEventHandler): this;
off(type: 'pm:enable', fn?: PM.EnableEventHandler): this;
/** Fired when edit mode on a layer is disabled. */
on(type: 'pm:disable', fn: PM.DisableEventHandler): this;
once(type: 'pm:disable', fn: PM.DisableEventHandler): this;
off(type: 'pm:disable', fn?: PM.DisableEventHandler): this;
/** Fired when a vertex is added. */
on(type: 'pm:vertexadded', fn: PM.VertexAddedEventHandler2): this;
once(type: 'pm:vertexadded', fn: PM.VertexAddedEventHandler2): this;
off(type: 'pm:vertexadded', fn?: PM.VertexAddedEventHandler2): this;
/** Fired when a vertex is removed. */
on(type: 'pm:vertexremoved', fn: PM.VertexRemovedEventHandler): this;
once(type: 'pm:vertexremoved', fn: PM.VertexRemovedEventHandler): this;
off(type: 'pm:vertexremoved', fn?: PM.VertexRemovedEventHandler): this;
/** Fired when a vertex is clicked. */
on(type: 'pm:vertexclick', fn: PM.VertexClickEventHandler): this;
once(type: 'pm:vertexclick', fn: PM.VertexClickEventHandler): this;
off(type: 'pm:vertexclick', fn?: PM.VertexClickEventHandler): this;
/** Fired when dragging of a marker which corresponds to a vertex starts. */
on(type: 'pm:markerdragstart', fn: PM.MarkerDragStartEventHandler): this;
once(type: 'pm:markerdragstart', fn: PM.MarkerDragStartEventHandler): this;
off(type: 'pm:markerdragstart', fn?: PM.MarkerDragStartEventHandler): this;
/** Fired when dragging a vertex-marker. */
on(type: 'pm:markerdrag', fn: PM.MarkerDragEventHandler): this;
once(type: 'pm:markerdrag', fn: PM.MarkerDragEventHandler): this;
off(type: 'pm:markerdrag', fn?: PM.MarkerDragEventHandler): this;
/** Fired when dragging of a vertex-marker ends. */
on(type: 'pm:markerdragend', fn: PM.MarkerDragEndEventHandler): this;
once(type: 'pm:markerdragend', fn: PM.MarkerDragEndEventHandler): this;
off(type: 'pm:markerdragend', fn?: PM.MarkerDragEndEventHandler): this;
/** Fired when coords of a layer are reset. E.g. by self-intersection.. */
on(type: 'pm:layerreset', fn: PM.LayerResetEventHandler): this;
once(type: 'pm:layerreset', fn: PM.LayerResetEventHandler): this;
off(type: 'pm:layerreset', fn?: PM.LayerResetEventHandler): this;
/** When allowSelfIntersection: false, this event is fired as soon as a self-intersection is detected. */
on(type: 'pm:intersect', fn: PM.IntersectEventHandler): this;
once(type: 'pm:intersect', fn: PM.IntersectEventHandler): this;
off(type: 'pm:intersect', fn?: PM.IntersectEventHandler): this;
/** Fired coordinates of the layer changed. */
on(type: 'pm:change', fn: PM.ChangeEventHandler): this;
once(type: 'pm:change', fn: PM.ChangeEventHandler): this;
off(type: 'pm:change', fn?: PM.ChangeEventHandler): this;
/** Fired when position / coordinates of a layer changed. */
on(type: 'pm:textchange', fn: PM.TextChangeEventHandler): this;
once(type: 'pm:textchange', fn: PM.TextChangeEventHandler): this;
off(type: 'pm:textchange', fn?: PM.TextChangeEventHandler): this;
/******************************************
*
* TODO: EDIT MODE EVENTS ON MAP ONLY
*
********************************************/
/** Fired when Edit Mode is toggled. */
on(
type: 'pm:globaleditmodetoggled',
fn: PM.GlobalEditModeToggledEventHandler
): this;
once(
type: 'pm:globaleditmodetoggled',
fn: PM.GlobalEditModeToggledEventHandler
): this;
off(
type: 'pm:globaleditmodetoggled',
fn?: PM.GlobalEditModeToggledEventHandler
): this;
/******************************************
*
* TODO: DRAG MODE EVENTS ON MAP ONLY
*
********************************************/
/** Fired when Drag Mode is toggled. */
on(
type: 'pm:globaldragmodetoggled',
fn: PM.GlobalDragModeToggledEventHandler
): this;
once(
type: 'pm:globaldragmodetoggled',
fn: PM.GlobalDragModeToggledEventHandler
): this;
off(
type: 'pm:globaldragmodetoggled',
fn?: PM.GlobalDragModeToggledEventHandler
): this;
/******************************************
*
* TODO: DRAG MODE EVENTS ON LAYER ONLY
*
********************************************/
/** Fired when a layer starts being dragged. */
on(type: 'pm:dragstart', fn: PM.DragStartEventHandler): this;
once(type: 'pm:dragstart', fn: PM.DragStartEventHandler): this;
off(type: 'pm:dragstart', fn?: PM.DragStartEventHandler): this;
/** Fired when a layer is dragged. */
on(type: 'pm:drag', fn: PM.DragEventHandler): this;
once(type: 'pm:drag', fn: PM.DragEventHandler): this;
off(type: 'pm:drag', fn?: PM.DragEventHandler): this;
/** Fired when a layer stops being dragged. */
on(type: 'pm:dragend', fn: PM.DragEndEventHandler): this;
once(type: 'pm:dragend', fn: PM.DragEndEventHandler): this;
off(type: 'pm:dragend', fn?: PM.DragEndEventHandler): this;
/** Fired when drag mode on a layer is enabled. */
on(type: 'pm:dragenable', fn: PM.DragEnableEventHandler): this;
once(type: 'pm:dragenable', fn: PM.DragEnableEventHandler): this;
off(type: 'pm:dragenable', fn?: PM.DragEnableEventHandler): this;
/** Fired when drag mode on a layer is disabled. */
on(type: 'pm:dragdisable', fn: PM.DragDisableEventHandler): this;
once(type: 'pm:dragdisable', fn: PM.DragDisableEventHandler): this;
off(type: 'pm:dragdisable', fn?: PM.DragDisableEventHandler): this;
/******************************************
*
* TODO: REMOVE MODE EVENTS ON MAP ONLY
*
********************************************/
/** Fired when Removal Mode is toggled. */
on(
type: 'pm:globalremovalmodetoggled',
fn: PM.GlobalRemovalModeToggledEventHandler
): this;
once(
type: 'pm:globalremovalmodetoggled',
fn: PM.GlobalRemovalModeToggledEventHandler
): this;
off(
type: 'pm:globalremovalmodetoggled',
fn?: PM.GlobalRemovalModeToggledEventHandler
): this;
/******************************************
*
* TODO: CUT MODE EVENTS ON MAP ONLY
*
********************************************/
/** Fired when a layer is removed via Removal Mode. */
on(
type: 'pm:globalcutmodetoggled',
fn: PM.GlobalCutModeToggledEventHandler
): this;
once(
type: 'pm:globalcutmodetoggled',
fn: PM.GlobalCutModeToggledEventHandler
): this;
off(
type: 'pm:globalcutmodetoggled',
fn?: PM.GlobalCutModeToggledEventHandler
): this;
/******************************************
*
* TODO: ROTATE MODE EVENTS ON MAP ONLY
*
********************************************/
/** Fired when Rotate Mode is toggled. */
on(
type: 'pm:globalrotatemodetoggled',
fn: PM.GlobalRotateModeToggledEventHandler
): this;
once(
type: 'pm:globalrotatemodetoggled',
fn: PM.GlobalRotateModeToggledEventHandler
): this;
off(
type: 'pm:globalrotatemodetoggled',
fn?: PM.GlobalRotateModeToggledEventHandler
): this;
/******************************************
*
* TODO: TRANSLATION EVENTS ON MAP ONLY
*
********************************************/
/** Standard Leaflet event. Fired when any layer is removed. */
on(type: 'pm:langchange', fn: PM.LangChangeEventHandler): this;
once(type: 'pm:langchange', fn: PM.LangChangeEventHandler): this;
off(type: 'pm:langchange', fn?: PM.LangChangeEventHandler): this;
/******************************************
*
* TODO: CONTROL EVENTS ON MAP ONLY
*
********************************************/
/** Fired when a Toolbar button is clicked. */
on(type: 'pm:buttonclick', fn: PM.ButtonClickEventHandler): this;
once(type: 'pm:buttonclick', fn: PM.ButtonClickEventHandler): this;
off(type: 'pm:buttonclick', fn?: PM.ButtonClickEventHandler): this;
/** Fired when a Toolbar action is clicked. */
on(type: 'pm:actionclick', fn: PM.ActionClickEventHandler): this;
once(type: 'pm:actionclick', fn: PM.ActionClickEventHandler): this;
off(type: 'pm:actionclick', fn?: PM.ActionClickEventHandler): this;
/******************************************
*
* TODO: Keyboard EVENT ON MAP ONLY
*
********************************************/
/** Fired when `keydown` or `keyup` on the document is fired. */
on(type: 'pm:keyevent', fn: PM.KeyboardKeyEventHandler): this;
once(type: 'pm:keyevent', fn: PM.KeyboardKeyEventHandler): this;
off(type: 'pm:keyevent', fn?: PM.KeyboardKeyEventHandler): this;
}
namespace PM {
export const version: string;
/** Supported shape names. 'ImageOverlay' is in Edit Mode only. Also accepts custom shape name. */
type SUPPORTED_SHAPES =
| 'Marker'
| 'Circle'
| 'Line'
| 'Rectangle'
| 'Polygon'
| 'Cut'
| 'CircleMarker'
| 'ImageOverlay'
| 'Text'
| string;
type SupportLocales =
| 'cz'
| 'da'
| 'de'
| 'el'
| 'en'
| 'es'
| 'fa'
| 'fr'
| 'hu'
| 'id'
| 'it'
| 'ja'
| 'nl'
| 'no'
| 'pl'
| 'pt_br'
| 'ro'
| 'ru'
| 'sv'
| 'tr'
| 'ua'
| 'zh'
| 'zh_tw';
/**
* Changes default registration of leaflet-geoman on leaflet layers.
*
* @param optIn - if true, a layers pmIgnore property has to be set to false to get initiated.
*/
function setOptIn(optIn: boolean): void;
/**
* Enable leaflet-geoman on an ignored layer.
*
* @param layer - re-reads layer.options.pmIgnore to initialize leaflet-geoman.
*/
function reInitLayer(layer: L.Layer): void;
/**
* PM map interface.
*/
interface PMMap
extends PMDrawMap,
PMEditMap,
PMDragMap,
PMRemoveMap,
PMCutMap,
PMRotateMap {
Toolbar: PMMapToolbar;
Keyboard: PMMapKeyboard;
/** Adds the Toolbar to the map. */
addControls(options?: ToolbarOptions): void;
/** Toggle the visiblity of the Toolbar. */
removeControls(): void;
/** Returns true if the Toolbar is visible on the map. */
controlsVisible(): boolean;
/** Toggle the visiblity of the Toolbar. */
toggleControls(): void;
setLang(
lang: SupportLocales,
customTranslations?: Translations,
fallbackLanguage?: string
): void;
/** Set globalOptions and apply them. */
setGlobalOptions(options: GlobalOptions): void;
/** Apply the current globalOptions to all existing layers. */
applyGlobalOptions(): void;
/** Returns the globalOptions. */
getGlobalOptions(): GlobalOptions;
}
class Translations {
tooltips?: {
placeMarker?: string;
firstVertex?: string;
continueLine?: string;
finishLine?: string;
finishPoly?: string;
finishRect?: string;
startCircle?: string;
finishCircle?: string;
placeCircleMarker?: string;
};
actions?: {
finish?: string;
cancel?: string;
removeLastVertex?: string;
};
buttonTitles?: {
drawMarkerButton?: string;
drawPolyButton?: string;
drawLineButton?: string;
drawCircleButton?: string;
drawRectButton?: string;
editButton?: string;
dragButton?: string;
cutButton?: string;
deleteButton?: string;
drawCircleMarkerButton?: string;
};
}
type ACTION_NAMES = 'cancel' | 'removeLastVertex' | 'finish' | 'finishMode';
class Action {
text: string;
onClick?: (e: any) => void;
}
type TOOLBAR_CONTROL_ORDER =
| 'drawMarker'
| 'drawCircleMarker'
| 'drawPolyline'
| 'drawRectangle'
| 'drawPolygon'
| 'drawCircle'
| 'editMode'
| 'dragMode'
| 'cutPolygon'
| 'removalMode'
| 'rotateMode'
| 'drawText'
| string;
interface PMMapToolbar {
/** Pass an array of button names to reorder the buttons in the Toolbar. */
changeControlOrder(order?: TOOLBAR_CONTROL_ORDER[]): void;
/** Receive the current order with. */
getControlOrder(): TOOLBAR_CONTROL_ORDER[];
/** The position of a block (draw, edit, custom, options⭐) in the Toolbar can be changed. If not set, the value from position of the Toolbar is taken. */
setBlockPosition(
block: 'draw' | 'edit' | 'custom' | 'options',
position: L.ControlPosition
): void;
/** Returns a Object with the positions for all blocks */
getBlockPositions(): BlockPositions;
/** To add a custom Control to the Toolbar */
createCustomControl(options: CustomControlOptions): void;
/** Creates a copy of a draw Control. Returns the drawInstance and the control. */
copyDrawControl(
copyInstance: string,
options?: CustomControlOptions
): void;
/** Change the actions of an existing button. */
changeActionsOfControl(
name: string,
actions: (ACTION_NAMES | Action)[]
): void;
/** Disable button by control name */
setButtonDisabled(name: TOOLBAR_CONTROL_ORDER, state: boolean): void;
}
type KEYBOARD_EVENT_TYPE = 'current' | 'keydown' | 'keyup';
interface PMMapKeyboard {
/** Pass an array of button names to reorder the buttons in the Toolbar. */
getLastKeyEvent(type: KEYBOARD_EVENT_TYPE[]): KeyboardKeyEventHandler;
/** Returns the current pressed key. [KeyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key). */
getPressedKey(): string;
/** Returns true if the `Shift` key is currently pressed. */
isShiftKeyPressed(): boolean;
/** Returns true if the `Alt` key is currently pressed. */
isAltKeyPressed(): boolean;
/** Returns true if the `Ctrl` key is currently pressed. */
isCtrlKeyPressed(): boolean;
/** Returns true if the `Meta` key is currently pressed. */
isMetaKeyPressed(): boolean;
}
interface Button {
/** Actions */
actions: (ACTION_NAMES | Action)[];
/** Function fired after clicking the control. */
afterClick: () => void;
/** CSS class with the Icon. */
className: string;
/** If true, other buttons will be disabled on click (default: true) */
disableOtherButtons: boolean;
/** Control can be toggled. */
doToggle: boolean;
/** Extending Class f. ex. Line, Polygon, ... L.PM.Draw.EXTENDINGCLASS */
jsClass: string;
/** Function fired when clicking the control. */
onClick: () => void;
position: L.ControlPosition;
/** Text showing when you hover the control. */
title: string;
/** Toggle state true -> enabled, false -> disabled (default: false) */
toggleStatus: boolean;
/** Block of the control. 'options' is ⭐ only. */
tool?: 'draw' | 'edit' | 'custom' | 'options';
}
interface CustomControlOptions {
/** Name of the control */
name: string;
/** Block of the control. 'options' is ⭐ only. */
block?: 'draw' | 'edit' | 'custom' | 'options';
/** Text showing when you hover the control. */
title?: string;
/** CSS class with the Icon. */
className?: string;
/** Function fired when clicking the control. */
onClick?: () => void;
/** Function fired after clicking the control. */
afterClick?: () => void;
/** Actions */
actions?: (ACTION_NAMES | Action)[];
/** Control can be toggled. */
toggle?: boolean;
/** Control is disabled. */
disabled?: boolean;
}
type PANE =
| 'mapPane'
| 'tilePane'
| 'overlayPane'
| 'shadowPane'
| 'markerPane'
| 'tooltipPane'
| 'popupPane'
| string;
interface GlobalOptions extends DrawModeOptions, EditModeOptions {
/** Add the created layers to a layergroup instead to the map. */
layerGroup?: L.Map | L.LayerGroup;
/** Prioritize the order of snapping. Default: ['Marker','CircleMarker','Circle','Line','Polygon','Rectangle']. */
snappingOrder?: SUPPORTED_SHAPES[];
/** Defines in which panes the layers and helper vertices are created. Default: { vertexPane: 'markerPane', layerPane: 'overlayPane', markerPane: 'markerPane' } */
panes?: { vertexPane?: PANE; layerPane?: PANE; markerPane?: PANE };
}
interface PMDrawMap {
/** Enable Draw Mode with the passed shape. */
enableDraw(shape: SUPPORTED_SHAPES, options?: DrawModeOptions): void;
/** Disable all drawing */
disableDraw(shape?: SUPPORTED_SHAPES): void;
/** Draw */
Draw: Draw;
/** Returns true if global Draw Mode is enabled. false when disabled. */
globalDrawModeEnabled(): boolean;
/** Customize the style of the drawn layer. Only for L.Path layers. Shapes can be excluded with a ignoreShapes array or merged with the current style with merge: true in optionsModifier. */
setPathOptions(
options: L.PathOptions,
optionsModifier?: { ignoreShapes?: SUPPORTED_SHAPES[]; merge?: boolean }
): void;
/** Returns all Geoman layers on the map as array. Pass true to get a L.FeatureGroup. */
getGeomanLayers(asFeatureGroup: true): L.FeatureGroup;
getGeomanLayers(asFeatureGroup?: false): L.Layer[];
/** Returns all Geoman draw layers on the map as array. Pass true to get a L.FeatureGroup. */
getGeomanDrawLayers(asFeatureGroup: true): L.FeatureGroup;
getGeomanDrawLayers(asFeatureGroup?: false): L.Layer[];
}
interface PMEditMap {
/** Enables edit mode. The passed options are preserved, even when the mode is enabled via the Toolbar */
enableGlobalEditMode(options?: EditModeOptions): void;
/** Disables global edit mode. */
disableGlobalEditMode(): void;
/** Toggles global edit mode. */
toggleGlobalEditMode(options?: EditModeOptions): void;
/** Returns true if global edit mode is enabled. false when disabled. */
globalEditModeEnabled(): boolean;
}
interface PMDragMap {
/** Enables global drag mode. */
enableGlobalDragMode(): void;
/** Disables global drag mode. */
disableGlobalDragMode(): void;
/** Toggles global drag mode. */
toggleGlobalDragMode(): void;
/** Returns true if global drag mode is enabled. false when disabled. */
globalDragModeEnabled(): boolean;
}
interface PMRemoveMap {
/** Enables global removal mode. */
enableGlobalRemovalMode(): void;
/** Disables global removal mode. */
disableGlobalRemovalMode(): void;
/** Toggles global removal mode. */
toggleGlobalRemovalMode(): void;
/** Returns true if global removal mode is enabled. false when disabled. */
globalRemovalModeEnabled(): boolean;
}
interface PMCutMap {
/** Enables global cut mode. */
enableGlobalCutMode(options?: CutModeOptions): void;
/** Disables global cut mode. */
disableGlobalCutMode(): void;
/** Toggles global cut mode. */
toggleGlobalCutMode(options?: CutModeOptions): void;
/** Returns true if global cut mode is enabled. false when disabled. */
globalCutModeEnabled(): boolean;
}
interface PMRotateMap {
/** Enables global rotate mode. */
enableGlobalRotateMode(): void;
/** Disables global rotate mode. */
disableGlobalRotateMode(): void;
/** Toggles global rotate mode. */
toggleGlobalRotateMode(): void;
/** Returns true if global rotate mode is enabled. false when disabled. */
globalRotateModeEnabled(): boolean;
}
interface PMRotateLayer {
/** Enables rotate mode on the layer. */
enableRotate(): void;
/** Disables rotate mode on the layer. */
disableRotate(): void;
/** Toggles rotate mode on the layer. */
rotateEnabled(): void;
/** Rotates the layer by x degrees. */
rotateLayer(degrees: number): void;
/** Rotates the layer to x degrees. */
rotateLayerToAngle(degrees: number): void;
/** Returns the angle of the layer in degrees. */
getAngle(): number;
}
interface Draw {
/** Array of available shapes. */
getShapes(): SUPPORTED_SHAPES[];
/** Returns the active shape. */
getActiveShape(): SUPPORTED_SHAPES;
/** Set path options */
setPathOptions(options: L.PathOptions): void;
/** Set options */
setOptions(options: DrawModeOptions): void;
/** Get options */
getOptions(): DrawModeOptions;
}
interface CutModeOptions {
allowSelfIntersection?: boolean;
}
type VertexValidationHandler = (e: {
layer: L.Layer;
marker: L.Marker;
event: any;
}) => boolean;
interface EditModeOptions {
/** Enable snapping to other layers vertices for precision drawing. Can be disabled by holding the ALT key (default:true). */
snappable?: boolean;
/** The distance to another vertex when a snap should happen (default:20). */
snapDistance?: number;
/** Allow self intersections (default:true). */
allowSelfIntersection?: boolean;
/** Allow self intersections (default:true). */
allowSelfIntersectionEdit?: boolean;
/** Disable the removal of markers via right click / vertices via removeVertexOn. (default:false). */
preventMarkerRemoval?: boolean;
/** If true, vertex removal that cause a layer to fall below their minimum required vertices will remove the entire layer. If false, these vertices can't be removed. Minimum vertices are 2 for Lines and 3 for Polygons (default:true). */
removeLayerBelowMinVertexCount?: boolean;
/** Defines which layers should dragged with this layer together. true syncs all layers in the same LayerGroup(s) or you pass an `Array` of layers to sync. (default:false). */
syncLayersOnDrag?: L.Layer[] | boolean;
/** Edit-Mode for the layer can disabled (`pm.enable()`). (default:true). */
allowEditing?: boolean;
/** Removing can be disabled for the layer. (default:true). */
allowRemoval?: boolean;
/** Layer can be prevented from cutting. (default:true). */
allowCutting?: boolean;
/** Layer can be prevented from rotation. (default:true). */
allowRotation?: boolean;
/** Dragging can be disabled for the layer. (default:true). */
draggable?: boolean;
/** Leaflet layer event to add a vertex to a Line or Polygon, like dblclick. (default:click). */
addVertexOn?:
| 'click'
| 'dblclick'
| 'mousedown'
| 'mouseover'
| 'mouseout'
| 'contextmenu';
/** A function for validation if a vertex (of a Line / Polygon) is allowed to add. It passes a object with `[layer, marker, event}`. For example to check if the layer has a certain property or if the `Ctrl` key is pressed. (default:undefined). */
addVertexValidation?: undefined | VertexValidationHandler;
/** Leaflet layer event to remove a vertex from a Line or Polygon, like dblclick. (default:contextmenu). */
removeVertexOn?:
| 'click'
| 'dblclick'
| 'mousedown'
| 'mouseover'
| 'mouseout'
| 'contextmenu';
/** A function for validation if a vertex (of a Line / Polygon) is allowed to remove. It passes a object with `[layer, marker, event}`. For example to check if the layer has a certain property or if the `Ctrl` key is pressed. */
removeVertexValidation?: undefined | VertexValidationHandler;
/** A function for validation if a vertex / helper-marker is allowed to move / drag. It passes a object with `[layer, marker, event}`. For example to check if the layer has a certain property or if the `Ctrl` key is pressed. */
moveVertexValidation?: undefined | VertexValidationHandler;
/** Shows only n markers closest to the cursor. Use -1 for no limit (default:-1). */
limitMarkersToCount?: number;
/** Shows markers when under the given zoom level ⭐ */
limitMarkersToZoom?: number;
/** Shows only markers in the viewport ⭐ */
limitMarkersToViewport?: boolean;
/** Shows markers only after the layer was clicked ⭐ */
limitMarkersToClick?: boolean;
/** Pin shared vertices/markers together during edit ⭐ */
pinning?: boolean;
/** Hide the middle Markers in edit mode from Polyline and Polygon. */
hideMiddleMarkers?: boolean;
}
interface TextOptions {
/** Predefined text for Text-Layer. */
text?: string;
/** Directly after placing the Text-Layer text editing is activated. */
focusAfterDraw?: boolean;
/** The text layer is removed if no text is written. */