@@ -820,6 +820,17 @@ declare module 'leaflet' {
820820 on ( type : 'pm:globalcancel' , fn : PM . GlobalCancelEventHandler ) : this;
821821 once ( type : 'pm:globalcancel' , fn : PM . GlobalCancelEventHandler ) : this;
822822 off ( type : 'pm:globalcancel' , fn ?: PM . GlobalCancelEventHandler ) : this;
823+
824+ /******************************************
825+ *
826+ * TODO: ERROR EVENTS ON MAP ONLY
827+ *
828+ ********************************************/
829+
830+ /** Fired when an error is thrown. */
831+ on ( type : 'pm:error' , fn : PM . ErrorEventHandler ) : this;
832+ once ( type : 'pm:error' , fn : PM . ErrorEventHandler ) : this;
833+ off ( type : 'pm:error' , fn ?: PM . ErrorEventHandler ) : this;
823834 }
824835
825836 namespace PM {
@@ -1073,7 +1084,7 @@ declare module 'leaflet' {
10731084 /** Creates a copy of a draw Control. Returns the drawInstance and the control. */
10741085 copyDrawControl (
10751086 copyInstance : string ,
1076- options ? : CustomControlOptions
1087+ options : CustomControlOptions
10771088 ) : {
10781089 drawInstance : Draw ;
10791090 control : L . Control ;
@@ -1116,33 +1127,33 @@ declare module 'leaflet' {
11161127
11171128 interface Button {
11181129 /** Actions */
1119- actions : ( ACTION_NAMES | Action ) [ ] ;
1130+ actions ? : ( ACTION_NAMES | Action ) [ ] ;
11201131
11211132 /** Function fired after clicking the control. */
1122- afterClick : ( ) => void ;
1133+ afterClick ? : ( ) => void ;
11231134
11241135 /** CSS class with the Icon. */
1125- className : string ;
1136+ className ? : string ;
11261137
11271138 /** If true, other buttons will be disabled on click (default: true) */
1128- disableOtherButtons : boolean ;
1139+ disableOtherButtons ? : boolean ;
11291140
11301141 /** Control can be toggled. */
1131- doToggle : boolean ;
1142+ doToggle ? : boolean ;
11321143
11331144 /** Extending Class f. ex. Line, Polygon, ... L.PM.Draw.EXTENDINGCLASS */
1134- jsClass : string ;
1145+ jsClass ? : string ;
11351146
11361147 /** Function fired when clicking the control. */
1137- onClick : ( ) => void ;
1148+ onClick ? : ( ) => void ;
11381149
1139- position : L . ControlPosition ;
1150+ position ? : L . ControlPosition ;
11401151
11411152 /** Text showing when you hover the control. */
1142- title : string ;
1153+ title ? : string ;
11431154
11441155 /** Toggle state true -> enabled, false -> disabled (default: false) */
1145- toggleStatus : boolean ;
1156+ toggleStatus ? : boolean ;
11461157
11471158 /** Block of the control. 'options' is ⭐ only. */
11481159 tool ?: 'draw' | 'edit' | 'custom' | 'options' ;
@@ -1258,8 +1269,11 @@ declare module 'leaflet' {
12581269
12591270 /** 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. */
12601271 setPathOptions (
1261- options : L . PathOptions ,
1262- optionsModifier ?: { ignoreShapes ?: SUPPORTED_SHAPES [ ] ; merge ?: boolean }
1272+ options : L . PathOptions | L . CircleMarkerOptions ,
1273+ optionsModifier ?: {
1274+ ignoreShapes ?: SUPPORTED_SHAPES [ ] ,
1275+ merge ?: boolean
1276+ }
12631277 ) : void ;
12641278
12651279 /** Returns all Geoman layers on the map as array. Pass true to get a L.FeatureGroup. */
@@ -1612,15 +1626,15 @@ declare module 'leaflet' {
16121626 /** Returns the active shape. */
16131627 getActiveShape ( ) : SUPPORTED_SHAPES ;
16141628
1615- [ key : SUPPORTED_SHAPES ] : DrawShape ;
1629+ [ key : string ] : DrawShape | ( ( ... args : any [ ] ) => any ) ;
16161630 }
16171631
16181632 interface DrawShape {
16191633 /** Applies the styles (templineStyle, hintlineStyle, pathOptions, markerStyle) to the drawing layer. map.pm.Draw.Line.setStyle(options). */
1620- setStyle ( options : L . PathOptions ) : void ;
1634+ setStyle ( options : L . PathOptions | L . CircleMarkerOptions ) : void ;
16211635
16221636 /** Set path options */
1623- setPathOptions ( options : L . PathOptions ) : void ;
1637+ setPathOptions ( options : L . PathOptions | L . CircleMarkerOptions ) : void ;
16241638
16251639 /** Set options */
16261640 setOptions ( options : DrawModeOptions ) : void ;
@@ -1732,7 +1746,7 @@ declare module 'leaflet' {
17321746 | 'contextmenu' ;
17331747
17341748 /** 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). */
1735- addVertexValidation ?: undefined | VertexValidationHandler ;
1749+ addVertexValidation ?: VertexValidationHandler ;
17361750
17371751 /** Leaflet layer event to remove a vertex from a Line or Polygon, like dblclick. (default:contextmenu). */
17381752 removeVertexOn ?:
@@ -1744,10 +1758,10 @@ declare module 'leaflet' {
17441758 | 'contextmenu' ;
17451759
17461760 /** 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. */
1747- removeVertexValidation ?: undefined | VertexValidationHandler ;
1761+ removeVertexValidation ?: VertexValidationHandler ;
17481762
17491763 /** 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. */
1750- moveVertexValidation ?: undefined | VertexValidationHandler ;
1764+ moveVertexValidation ?: VertexValidationHandler ;
17511765
17521766 /** Shows only n markers closest to the cursor. Use -1 for no limit (default:-1). */
17531767 limitMarkersToCount ?: number ;
@@ -1771,46 +1785,46 @@ declare module 'leaflet' {
17711785 snapGuidesAngles ?: number [ ] ;
17721786
17731787 /** Styles the border helpline. ⭐ */
1774- scaleBorderStyle : L . PathOptions ;
1788+ scaleBorderStyle ? : L . PathOptions ;
17751789
17761790 /** Scale origin is the center, else it is the opposite corner. If false Alt-Key can be used. (default:true). ⭐ */
1777- centerScaling : boolean ;
1791+ centerScaling ? : boolean ;
17781792
17791793 /** Width and height are scaled with the same ratio. If false Shift-Key can be used. (default:true). ⭐ */
1780- uniformScaling : boolean ;
1794+ uniformScaling ? : boolean ;
17811795
17821796 /** Layer can be prevented from auto tracing. (default:true). ⭐ */
1783- allowAutoTracing : boolean ;
1797+ allowAutoTracing ? : boolean ;
17841798
17851799 /** Add Vertices while clicking on the line of Polyline or Polygon. (default:true). ⭐ */
1786- addVertexOnClick : boolean ;
1800+ addVertexOnClick ? : boolean ;
17871801
17881802 /** Layer can be prevented from pinning. (default:true). ⭐ */
1789- allowPinning : boolean ;
1803+ allowPinning ? : boolean ;
17901804
17911805 /** Styles the Snap Guides. ⭐ */
1792- snapGuidesStyle : L . PathOptions ;
1806+ snapGuidesStyle ? : L . PathOptions ;
17931807
17941808 /** Enables the Snap guides. (default:false). ⭐ */
1795- showSnapGuides : boolean ;
1809+ showSnapGuides ? : boolean ;
17961810
17971811 /** Layer can be prevented from used in Union Mode. (default:true). ⭐ */
1798- allowUnion : boolean ;
1812+ allowUnion ? : boolean ;
17991813
18001814 /** Layer can be prevented from used in Difference Mode. (default:true). ⭐ */
1801- allowDifference : boolean ;
1815+ allowDifference ? : boolean ;
18021816
18031817 /** Selecting via Lasso can be disabled for the layer. (default:true). ⭐ */
1804- lassoSelectable : boolean ;
1818+ lassoSelectable ? : boolean ;
18051819
18061820 /** While editing the layer needs to be contained in one of the layers in the Array. ⭐ */
1807- requireContainment : ( L . Polygon | L . Circle | L . ImageOverlay ) [ ] ;
1821+ requireContainment ? : ( L . Polygon | L . Circle | L . ImageOverlay ) [ ] ;
18081822
18091823 /** While editing the layer can't intersect with the layers in the Array. ⭐ */
1810- preventIntersection : L . Layer [ ] ;
1824+ preventIntersection ? : L . Layer [ ] ;
18111825
18121826 /** Layer can be prevented from scaling. (default:true). ⭐ */
1813- allowScale : boolean ;
1827+ allowScale ? : boolean ;
18141828 }
18151829
18161830 interface TextOptions {
@@ -1841,13 +1855,13 @@ declare module 'leaflet' {
18411855 allowSelfIntersection ?: boolean ;
18421856
18431857 /** Leaflet path options for the lines between drawn vertices/markers. (default:{color:'red'}). */
1844- templineStyle ?: L . CircleMarkerOptions ;
1858+ templineStyle ?: L . PathOptions | L . CircleMarkerOptions ;
18451859
18461860 /** Leaflet path options for the helper line between last drawn vertex and the cursor. (default:{color:'red',dashArray:[5,5]}). */
1847- hintlineStyle ?: L . PathOptions ;
1861+ hintlineStyle ?: L . PathOptions | L . CircleMarkerOptions ;
18481862
18491863 /** Leaflet path options for the drawn layer (Only for L.Path layers). (default:null). */
1850- pathOptions ?: L . PathOptions ;
1864+ pathOptions ?: L . PathOptions | L . CircleMarkerOptions ;
18511865
18521866 /** Leaflet marker options (only for drawing markers). (default:{draggable:true}). */
18531867 markerStyle ?: L . MarkerOptions ;
@@ -1907,19 +1921,19 @@ declare module 'leaflet' {
19071921 textOptions ?: TextOptions ;
19081922
19091923 /** Leaflet path options for the freehand polygon while drawing. To the resulting layer will be the pathOptions applied (default:null) ⭐ */
1910- freehandOptions : L . PathOptions ;
1924+ freehandOptions ? : L . PathOptions ;
19111925
19121926 /** Leaflet path options for the lasso polygon while drawing. The option `fill` will be always true. (default:null) ⭐ */
1913- lassoDrawOptions : L . PathOptions ;
1927+ lassoDrawOptions ? : L . PathOptions ;
19141928
19151929 /** Style / Geojson ooptions for custom shape. ⭐ */
19161930 customShapeGeoJSONOptions ?: L . GeoJSONOptions ;
19171931
19181932 /** While drawing one of the layers in the Array need to contain the new layer. ⭐ */
1919- requireContainment : ( L . Polygon | L . Circle | L . ImageOverlay ) [ ] ;
1933+ requireContainment ? : ( L . Polygon | L . Circle | L . ImageOverlay ) [ ] ;
19201934
19211935 /** While drawing the new layer can't intersect with one of the layers in the Array. ⭐ */
1922- preventIntersection : L . Layer [ ] ;
1936+ preventIntersection ? : L . Layer [ ] ;
19231937
19241938 /** Closes the Polygon while drawing. ⭐ */
19251939 closedPolygonEdge ?: boolean ;
@@ -1948,6 +1962,8 @@ declare module 'leaflet' {
19481962 snapVertex ?: boolean ;
19491963 }
19501964
1965+ type CancelActionModes = 'editMode' | 'dragMode' | 'removalMode' | 'rotateMode' | 'scaleMode' | 'lineSimplificationMode' ;
1966+
19511967 /**
19521968 * PM toolbar options.
19531969 */
@@ -2058,20 +2074,11 @@ declare module 'leaflet' {
20582074 lineSimplificationMode ?: boolean ;
20592075
20602076 /** Hide the cancel button for edit modes (default: []) ⭐ */
2061- hideCancelActionOf :
2062- | null
2063- | (
2064- | 'editMode'
2065- | 'dragMode'
2066- | 'removalMode'
2067- | 'rotateMode'
2068- | 'scaleMode'
2069- | 'lineSimplificationMode'
2070- ) [ ] ;
2077+ hideCancelActionOf ?: CancelActionModes [ ] ;
20712078
20722079 /** Adds custom button (default:true) */
20732080 // The type of custom buttons are always boolean but TS needs the other types defined too.
2074- [ key : string ] : L . ControlPosition | BlockPositions | boolean | undefined ;
2081+ [ key : string ] : L . ControlPosition | BlockPositions | boolean | undefined | CancelActionModes [ ] ;
20752082 }
20762083
20772084 /** the position of each block. */
@@ -2707,5 +2714,10 @@ declare module 'leaflet' {
27072714 * CANCEL MODE MAP EVENT HANDLERS
27082715 */
27092716 export type GlobalCancelEventHandler = ( e : { map : L . Map } ) => void ;
2717+
2718+ /**
2719+ * ERROR MAP EVENT HANDLERS
2720+ */
2721+ export type ErrorEventHandler = ( e : { message : string , source : string , payload : any } ) => void ;
27102722 }
27112723}
0 commit comments