1
|
|
-///
|
2
|
|
-/// Copyright © 2016-2021 The Thingsboard Authors
|
3
|
|
-///
|
4
|
|
-/// Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
|
-/// you may not use this file except in compliance with the License.
|
6
|
|
-/// You may obtain a copy of the License at
|
7
|
|
-///
|
8
|
|
-/// http://www.apache.org/licenses/LICENSE-2.0
|
9
|
|
-///
|
10
|
|
-/// Unless required by applicable law or agreed to in writing, software
|
11
|
|
-/// distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
|
-/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
|
-/// See the License for the specific language governing permissions and
|
14
|
|
-/// limitations under the License.
|
15
|
|
-///
|
16
|
|
-
|
17
|
|
-import * as leaflet from 'leaflet';
|
18
|
|
-
|
19
|
|
-declare module 'leaflet' {
|
20
|
|
-
|
21
|
|
- /**
|
22
|
|
- * Make geometries editable in Leaflet.
|
23
|
|
- *
|
24
|
|
- * This is not a plug and play UI, and will not. This is a minimal, lightweight, and fully extendable API to
|
25
|
|
- * control editing of geometries. So you can easily build your own UI with your own needs and choices.
|
26
|
|
- */
|
27
|
|
- interface EditableStatic {
|
28
|
|
- new (map: Map, options: EditOptions): Editable;
|
29
|
|
- }
|
30
|
|
-
|
31
|
|
- /**
|
32
|
|
- * Options to pass to L.Editable when instanciating.
|
33
|
|
- */
|
34
|
|
- interface EditOptions extends leaflet.MapOptions{
|
35
|
|
- /**
|
36
|
|
- * Whether to create a L.Editable instance at map init or not.
|
37
|
|
- */
|
38
|
|
- editable: boolean;
|
39
|
|
- /**
|
40
|
|
- * Class to be used when creating a new Polyline.
|
41
|
|
- */
|
42
|
|
- polylineClass?: object;
|
43
|
|
-
|
44
|
|
- /**
|
45
|
|
- * Class to be used when creating a new Polygon.
|
46
|
|
- */
|
47
|
|
- polygonClass?: object;
|
48
|
|
-
|
49
|
|
- /**
|
50
|
|
- * Class to be used when creating a new Marker.
|
51
|
|
- */
|
52
|
|
- markerClass?: object;
|
53
|
|
-
|
54
|
|
- /**
|
55
|
|
- * CSS class to be added to the map container while drawing.
|
56
|
|
- */
|
57
|
|
- drawingCSSClass?: string;
|
58
|
|
-
|
59
|
|
- /**
|
60
|
|
- * Layer used to store edit tools (vertex, line guide…).
|
61
|
|
- */
|
62
|
|
- editLayer?: LayerGroup<leaflet.Layer>;
|
63
|
|
-
|
64
|
|
- /**
|
65
|
|
- * Default layer used to store drawn features (marker, polyline…).
|
66
|
|
- */
|
67
|
|
- featuresLayer?: LayerGroup<Polyline|Polygon|Marker>;
|
68
|
|
-
|
69
|
|
- /**
|
70
|
|
- * Class to be used as vertex, for path editing.
|
71
|
|
- */
|
72
|
|
- vertexMarkerClass?: object;
|
73
|
|
-
|
74
|
|
- /**
|
75
|
|
- * Class to be used as middle vertex, pulled by the user to create a new point in the middle of a path.
|
76
|
|
- */
|
77
|
|
- middleMarkerClass?: object;
|
78
|
|
-
|
79
|
|
- /**
|
80
|
|
- * Class to be used as Polyline editor.
|
81
|
|
- */
|
82
|
|
- polylineEditorClass?: object;
|
83
|
|
-
|
84
|
|
- /**
|
85
|
|
- * Class to be used as Polygon editor.
|
86
|
|
- */
|
87
|
|
- polygonEditorClass?: object;
|
88
|
|
-
|
89
|
|
- /**
|
90
|
|
- * Class to be used as Marker editor.
|
91
|
|
- */
|
92
|
|
- markerEditorClass?: object;
|
93
|
|
-
|
94
|
|
- /**
|
95
|
|
- * Options to be passed to the line guides.
|
96
|
|
- */
|
97
|
|
- lineGuideOptions?: object;
|
98
|
|
-
|
99
|
|
- /**
|
100
|
|
- * Set this to true if you don't want middle markers.
|
101
|
|
- */
|
102
|
|
- skipMiddleMarkers?: boolean;
|
103
|
|
- }
|
104
|
|
-
|
105
|
|
- /**
|
106
|
|
- * Make geometries editable in Leaflet.
|
107
|
|
- *
|
108
|
|
- * This is not a plug and play UI, and will not. This is a minimal, lightweight, and fully extendable API to
|
109
|
|
- * control editing of geometries. So you can easily build your own UI with your own needs and choices.
|
110
|
|
- */
|
111
|
|
- interface Editable extends leaflet.Evented {
|
112
|
|
- /**
|
113
|
|
- * Options to pass to L.Editable when instanciating.
|
114
|
|
- */
|
115
|
|
- options: EditOptions;
|
116
|
|
-
|
117
|
|
- currentPolygon: Polyline|Polygon|Marker;
|
118
|
|
-
|
119
|
|
- /**
|
120
|
|
- * Start drawing a polyline. If latlng is given, a first point will be added. In any case, continuing on user
|
121
|
|
- * click. If options is given, it will be passed to the polyline class constructor.
|
122
|
|
- */
|
123
|
|
- startPolyline(latLng?: LatLng, options?: PolylineOptions): Polyline;
|
124
|
|
-
|
125
|
|
- /**
|
126
|
|
- * Start drawing a polygon. If latlng is given, a first point will be added. In any case, continuing on user
|
127
|
|
- * click. If options is given, it will be passed to the polygon class constructor.
|
128
|
|
- */
|
129
|
|
- startPolygon(latLng?: LatLng, options?: PolylineOptions): Polygon;
|
130
|
|
-
|
131
|
|
- /**
|
132
|
|
- * Start adding a marker. If latlng is given, the marker will be shown first at this point. In any case, it
|
133
|
|
- * will follow the user mouse, and will have a final latlng on next click (or touch). If options is given,
|
134
|
|
- * it will be passed to the marker class constructor.
|
135
|
|
- */
|
136
|
|
- startMarker(latLng?: LatLng, options?: MarkerOptions): Marker;
|
137
|
|
-
|
138
|
|
- /**
|
139
|
|
- * When you need to stop any ongoing drawing, without needing to know which editor is active.
|
140
|
|
- */
|
141
|
|
- stopDrawing(): void;
|
142
|
|
-
|
143
|
|
- /**
|
144
|
|
- * When you need to commit any ongoing drawing, without needing to know which editor is active.
|
145
|
|
- */
|
146
|
|
- commitDrawing(): void;
|
147
|
|
- }
|
148
|
|
-
|
149
|
|
- let Editable: EditableStatic;
|
150
|
|
-
|
151
|
|
- /**
|
152
|
|
- * EditableMixin is included to L.Polyline, L.Polygon and L.Marker. It adds the following methods to them.
|
153
|
|
- *
|
154
|
|
- * When editing is enabled, the editor is accessible on the instance with the editor property.
|
155
|
|
- */
|
156
|
|
- interface EditableMixin {
|
157
|
|
- /**
|
158
|
|
- * Enable editing, by creating an editor if not existing, and then calling enable on it.
|
159
|
|
- */
|
160
|
|
- enableEdit(map: L.Map): any;
|
161
|
|
-
|
162
|
|
- /**
|
163
|
|
- * Disable editing, also remove the editor property reference.
|
164
|
|
- */
|
165
|
|
- disableEdit(): void;
|
166
|
|
-
|
167
|
|
- /**
|
168
|
|
- * Enable or disable editing, according to current status.
|
169
|
|
- */
|
170
|
|
- toggleEdit(): void;
|
171
|
|
-
|
172
|
|
- /**
|
173
|
|
- * Return true if current instance has an editor attached, and this editor is enabled.
|
174
|
|
- */
|
175
|
|
- editEnabled(): boolean;
|
176
|
|
- }
|
177
|
|
-
|
178
|
|
- interface Map {
|
179
|
|
-
|
180
|
|
-
|
181
|
|
- /**
|
182
|
|
- * Options to pass to L.Editable when instanciating.
|
183
|
|
- */
|
184
|
|
- editOptions: MapOptions;
|
185
|
|
-
|
186
|
|
- /**
|
187
|
|
- * L.Editable plugin instance.
|
188
|
|
- */
|
189
|
|
- editTools: Editable;
|
190
|
|
- }
|
191
|
|
-
|
192
|
|
- // tslint:disable-next-line:no-empty-interface
|
193
|
|
- interface Polyline extends EditableMixin {}
|
194
|
|
-
|
195
|
|
- namespace Map {
|
196
|
|
- interface MapOptions {
|
197
|
|
- /**
|
198
|
|
- * Whether to create a L.Editable instance at map init or not.
|
199
|
|
- */
|
200
|
|
- editable?: boolean;
|
201
|
|
-
|
202
|
|
- /**
|
203
|
|
- * Options to pass to L.Editable when instanciating.
|
204
|
|
- */
|
205
|
|
- editOptions?: MapOptions;
|
206
|
|
- }
|
207
|
|
- }
|
208
|
|
-
|
209
|
|
- /**
|
210
|
|
- * When editing a feature (marker, polyline…), an editor is attached to it. This editor basically knows
|
211
|
|
- * how to handle the edition.
|
212
|
|
- */
|
213
|
|
- interface BaseEditor {
|
214
|
|
- /**
|
215
|
|
- * Set up the drawing tools for the feature to be editable.
|
216
|
|
- */
|
217
|
|
- enable(): MarkerEditor|PolylineEditor|PolygonEditor;
|
218
|
|
-
|
219
|
|
- /**
|
220
|
|
- * Remove editing tools.
|
221
|
|
- */
|
222
|
|
- disable(): MarkerEditor|PolylineEditor|PolygonEditor;
|
223
|
|
- }
|
224
|
|
-
|
225
|
|
- /**
|
226
|
|
- * Inherit from L.Editable.BaseEditor.
|
227
|
|
- * Inherited by L.Editable.PolylineEditor and L.Editable.PolygonEditor.
|
228
|
|
- */
|
229
|
|
- interface PathEditor extends BaseEditor {
|
230
|
|
- /**
|
231
|
|
- * Rebuild edit elements (vertex, middlemarker, etc.).
|
232
|
|
- */
|
233
|
|
- reset(): void;
|
234
|
|
- }
|
235
|
|
-
|
236
|
|
- /**
|
237
|
|
- * Inherit from L.Editable.PathEditor.
|
238
|
|
- */
|
239
|
|
- interface PolylineEditor extends PathEditor {
|
240
|
|
- /**
|
241
|
|
- * Set up drawing tools to continue the line forward.
|
242
|
|
- */
|
243
|
|
- continueForward(): void;
|
244
|
|
-
|
245
|
|
- /**
|
246
|
|
- * Set up drawing tools to continue the line backward.
|
247
|
|
- */
|
248
|
|
- continueBackward(): void;
|
249
|
|
- }
|
250
|
|
-
|
251
|
|
- /**
|
252
|
|
- * Inherit from L.Editable.PathEditor.
|
253
|
|
- */
|
254
|
|
- interface PolygonEditor extends PathEditor {
|
255
|
|
- /**
|
256
|
|
- * Set up drawing tools for creating a new hole on the polygon. If the latlng param is given, a first
|
257
|
|
- * point is created.
|
258
|
|
- */
|
259
|
|
- newHole(latlng: LatLng): void;
|
260
|
|
- }
|
261
|
|
-
|
262
|
|
- /**
|
263
|
|
- * Inherit from L.Editable.BaseEditor.
|
264
|
|
- */
|
265
|
|
- // tslint:disable-next-line:no-empty-interface
|
266
|
|
- interface MarkerEditor extends BaseEditor {}
|
267
|
|
-
|
268
|
|
- interface Marker extends EditableMixin, MarkerEditor {}
|
269
|
|
-
|
270
|
|
- interface Polyline extends EditableMixin, PolylineEditor {}
|
271
|
|
-
|
272
|
|
- interface Polygon extends EditableMixin, PolygonEditor {}
|
273
|
|
-
|
274
|
|
- function map(element: string | HTMLElement, options?: EditOptions): Map;
|
275
|
|
-} |