@signalk/charts-plugin 3.7.0 → 3.8.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.
Files changed (60) hide show
  1. package/.prettierignore +1 -0
  2. package/CHANGELOG.md +109 -0
  3. package/README.md +72 -0
  4. package/docs/screenshots/1_overview.png +0 -0
  5. package/docs/screenshots/2_region.png +0 -0
  6. package/docs/screenshots/3_jobs.png +0 -0
  7. package/package.json +13 -8
  8. package/plugin/cacheLayout.d.ts +72 -0
  9. package/plugin/cacheLayout.d.ts.map +1 -0
  10. package/plugin/cacheLayout.js +243 -0
  11. package/plugin/cacheLayout.js.map +1 -0
  12. package/plugin/chartDownloader.d.ts +122 -29
  13. package/plugin/chartDownloader.d.ts.map +1 -1
  14. package/plugin/chartDownloader.js +488 -313
  15. package/plugin/chartDownloader.js.map +1 -1
  16. package/plugin/chartDownloaderMBTilesHelpers.d.ts +10 -0
  17. package/plugin/chartDownloaderMBTilesHelpers.d.ts.map +1 -0
  18. package/plugin/chartDownloaderMBTilesHelpers.js +235 -0
  19. package/plugin/chartDownloaderMBTilesHelpers.js.map +1 -0
  20. package/plugin/chartDownloaderTileHelpers.d.ts +30 -0
  21. package/plugin/chartDownloaderTileHelpers.d.ts.map +1 -0
  22. package/plugin/chartDownloaderTileHelpers.js +277 -0
  23. package/plugin/chartDownloaderTileHelpers.js.map +1 -0
  24. package/plugin/charts.d.ts.map +1 -1
  25. package/plugin/charts.js +23 -5
  26. package/plugin/charts.js.map +1 -1
  27. package/plugin/constants.d.ts.map +1 -1
  28. package/plugin/index.d.ts.map +1 -1
  29. package/plugin/index.js +560 -47
  30. package/plugin/index.js.map +1 -1
  31. package/plugin/pluginStatus.js.map +1 -1
  32. package/plugin/projection.js.map +1 -1
  33. package/plugin/tileServer.d.ts +4 -2
  34. package/plugin/tileServer.d.ts.map +1 -1
  35. package/plugin/tileServer.js +37 -8
  36. package/plugin/tileServer.js.map +1 -1
  37. package/plugin/tokenProvider.d.ts +63 -0
  38. package/plugin/tokenProvider.d.ts.map +1 -0
  39. package/plugin/tokenProvider.js +258 -0
  40. package/plugin/tokenProvider.js.map +1 -0
  41. package/plugin/types.d.ts +37 -2
  42. package/plugin/types.d.ts.map +1 -1
  43. package/public/images/jobs.png +0 -0
  44. package/public/images/overview.png +0 -0
  45. package/public/images/region.png +0 -0
  46. package/public/index.html +392 -113
  47. package/public/js/index.js +620 -0
  48. package/public/leaflet/images/downloads.png +0 -0
  49. package/public/leaflet/images/layers-2x.png +0 -0
  50. package/public/leaflet/images/layers.png +0 -0
  51. package/public/leaflet/images/lifebuoy.png +0 -0
  52. package/public/leaflet/images/spritesheet-2x.png +0 -0
  53. package/public/leaflet/images/spritesheet.svg +156 -0
  54. package/public/leaflet/leaflet.css +677 -0
  55. package/public/leaflet/leaflet.draw.css +253 -0
  56. package/public/leaflet/leaflet.draw.js +2957 -0
  57. package/public/leaflet/leaflet.js +7467 -0
  58. package/public/style.css +351 -37
  59. package/docs/screenshots/1_placeholder.png +0 -0
  60. package/public/index.js +0 -349
@@ -0,0 +1,2957 @@
1
+ /*
2
+ Leaflet.draw 1.0.4, a plugin that adds drawing and editing tools to Leaflet powered maps.
3
+ (c) 2012-2017, Jacob Toye, Jon West, Smartrak, Leaflet
4
+
5
+ https://github.com/Leaflet/Leaflet.draw
6
+ http://leafletjs.com
7
+ */
8
+ !(function (t, e, i) {
9
+ function o(t, e) {
10
+ for (; (t = t.parentElement) && !t.classList.contains(e); );
11
+ return t
12
+ }
13
+ ;((L.drawVersion = '1.0.4'),
14
+ (L.Draw = {}),
15
+ (L.drawLocal = {
16
+ draw: {
17
+ toolbar: {
18
+ actions: { title: 'Cancel drawing', text: 'Cancel' },
19
+ finish: { title: 'Finish drawing', text: 'Finish' },
20
+ undo: { title: 'Delete last point drawn', text: 'Delete last point' },
21
+ buttons: {
22
+ polyline: 'Draw a polyline',
23
+ polygon: 'Draw a polygon',
24
+ rectangle: 'Draw a rectangle',
25
+ circle: 'Draw a circle',
26
+ marker: 'Draw a marker',
27
+ circlemarker: 'Draw a circlemarker'
28
+ }
29
+ },
30
+ handlers: {
31
+ circle: {
32
+ tooltip: { start: 'Click and drag to draw circle.' },
33
+ radius: 'Radius'
34
+ },
35
+ circlemarker: {
36
+ tooltip: { start: 'Click map to place circle marker.' }
37
+ },
38
+ marker: { tooltip: { start: 'Click map to place marker.' } },
39
+ polygon: {
40
+ tooltip: {
41
+ start: 'Click to start drawing shape.',
42
+ cont: 'Click to continue drawing shape.',
43
+ end: 'Click first point to close this shape.'
44
+ }
45
+ },
46
+ polyline: {
47
+ error: '<strong>Error:</strong> shape edges cannot cross!',
48
+ tooltip: {
49
+ start: 'Click to start drawing line.',
50
+ cont: 'Click to continue drawing line.',
51
+ end: 'Click last point to finish line.'
52
+ }
53
+ },
54
+ rectangle: {
55
+ tooltip: { start: 'Click and drag to draw rectangle.' }
56
+ },
57
+ simpleshape: { tooltip: { end: 'Release mouse to finish drawing.' } }
58
+ }
59
+ },
60
+ edit: {
61
+ toolbar: {
62
+ actions: {
63
+ save: { title: 'Save changes', text: 'Save' },
64
+ cancel: {
65
+ title: 'Cancel editing, discards all changes',
66
+ text: 'Cancel'
67
+ },
68
+ clearAll: { title: 'Clear all layers', text: 'Clear All' }
69
+ },
70
+ buttons: {
71
+ edit: 'Edit layers',
72
+ editDisabled: 'No layers to edit',
73
+ remove: 'Delete layers',
74
+ removeDisabled: 'No layers to delete'
75
+ }
76
+ },
77
+ handlers: {
78
+ edit: {
79
+ tooltip: {
80
+ text: 'Drag handles or markers to edit features.',
81
+ subtext: 'Click cancel to undo changes.'
82
+ }
83
+ },
84
+ remove: { tooltip: { text: 'Click on a feature to remove.' } }
85
+ }
86
+ }
87
+ }),
88
+ (L.Draw.Event = {}),
89
+ (L.Draw.Event.CREATED = 'draw:created'),
90
+ (L.Draw.Event.EDITED = 'draw:edited'),
91
+ (L.Draw.Event.DELETED = 'draw:deleted'),
92
+ (L.Draw.Event.DRAWSTART = 'draw:drawstart'),
93
+ (L.Draw.Event.DRAWSTOP = 'draw:drawstop'),
94
+ (L.Draw.Event.DRAWVERTEX = 'draw:drawvertex'),
95
+ (L.Draw.Event.EDITSTART = 'draw:editstart'),
96
+ (L.Draw.Event.EDITMOVE = 'draw:editmove'),
97
+ (L.Draw.Event.EDITRESIZE = 'draw:editresize'),
98
+ (L.Draw.Event.EDITVERTEX = 'draw:editvertex'),
99
+ (L.Draw.Event.EDITSTOP = 'draw:editstop'),
100
+ (L.Draw.Event.DELETESTART = 'draw:deletestart'),
101
+ (L.Draw.Event.DELETESTOP = 'draw:deletestop'),
102
+ (L.Draw.Event.TOOLBAROPENED = 'draw:toolbaropened'),
103
+ (L.Draw.Event.TOOLBARCLOSED = 'draw:toolbarclosed'),
104
+ (L.Draw.Event.MARKERCONTEXT = 'draw:markercontext'),
105
+ (L.Draw = L.Draw || {}),
106
+ (L.Draw.Feature = L.Handler.extend({
107
+ initialize: function (t, e) {
108
+ ;((this._map = t),
109
+ (this._container = t._container),
110
+ (this._overlayPane = t._panes.overlayPane),
111
+ (this._popupPane = t._panes.popupPane),
112
+ e &&
113
+ e.shapeOptions &&
114
+ (e.shapeOptions = L.Util.extend(
115
+ {},
116
+ this.options.shapeOptions,
117
+ e.shapeOptions
118
+ )),
119
+ L.setOptions(this, e))
120
+ var i = L.version.split('.')
121
+ 1 === parseInt(i[0], 10) && parseInt(i[1], 10) >= 2
122
+ ? L.Draw.Feature.include(L.Evented.prototype)
123
+ : L.Draw.Feature.include(L.Mixin.Events)
124
+ },
125
+ enable: function () {
126
+ this._enabled ||
127
+ (L.Handler.prototype.enable.call(this),
128
+ this.fire('enabled', { handler: this.type }),
129
+ this._map.fire(L.Draw.Event.DRAWSTART, { layerType: this.type }))
130
+ },
131
+ disable: function () {
132
+ this._enabled &&
133
+ (L.Handler.prototype.disable.call(this),
134
+ this._map.fire(L.Draw.Event.DRAWSTOP, { layerType: this.type }),
135
+ this.fire('disabled', { handler: this.type }))
136
+ },
137
+ addHooks: function () {
138
+ var t = this._map
139
+ t &&
140
+ (L.DomUtil.disableTextSelection(),
141
+ t.getContainer().focus(),
142
+ (this._tooltip = new L.Draw.Tooltip(this._map)),
143
+ L.DomEvent.on(this._container, 'keyup', this._cancelDrawing, this))
144
+ },
145
+ removeHooks: function () {
146
+ this._map &&
147
+ (L.DomUtil.enableTextSelection(),
148
+ this._tooltip.dispose(),
149
+ (this._tooltip = null),
150
+ L.DomEvent.off(this._container, 'keyup', this._cancelDrawing, this))
151
+ },
152
+ setOptions: function (t) {
153
+ L.setOptions(this, t)
154
+ },
155
+ _fireCreatedEvent: function (t) {
156
+ this._map.fire(L.Draw.Event.CREATED, { layer: t, layerType: this.type })
157
+ },
158
+ _cancelDrawing: function (t) {
159
+ 27 === t.keyCode &&
160
+ (this._map.fire('draw:canceled', { layerType: this.type }),
161
+ this.disable())
162
+ }
163
+ })),
164
+ (L.Draw.Polyline = L.Draw.Feature.extend({
165
+ statics: { TYPE: 'polyline' },
166
+ Poly: L.Polyline,
167
+ options: {
168
+ allowIntersection: !0,
169
+ repeatMode: !1,
170
+ drawError: { color: '#b00b00', timeout: 2500 },
171
+ icon: new L.DivIcon({
172
+ iconSize: new L.Point(8, 8),
173
+ className: 'leaflet-div-icon leaflet-editing-icon'
174
+ }),
175
+ touchIcon: new L.DivIcon({
176
+ iconSize: new L.Point(20, 20),
177
+ className: 'leaflet-div-icon leaflet-editing-icon leaflet-touch-icon'
178
+ }),
179
+ guidelineDistance: 20,
180
+ maxGuideLineLength: 4e3,
181
+ shapeOptions: {
182
+ stroke: !0,
183
+ color: '#3388ff',
184
+ weight: 4,
185
+ opacity: 0.5,
186
+ fill: !1,
187
+ clickable: !0
188
+ },
189
+ metric: !0,
190
+ feet: !0,
191
+ nautic: !1,
192
+ showLength: !0,
193
+ zIndexOffset: 2e3,
194
+ factor: 1,
195
+ maxPoints: 0
196
+ },
197
+ initialize: function (t, e) {
198
+ ;(L.Browser.touch && (this.options.icon = this.options.touchIcon),
199
+ (this.options.drawError.message =
200
+ L.drawLocal.draw.handlers.polyline.error),
201
+ e &&
202
+ e.drawError &&
203
+ (e.drawError = L.Util.extend(
204
+ {},
205
+ this.options.drawError,
206
+ e.drawError
207
+ )),
208
+ (this.type = L.Draw.Polyline.TYPE),
209
+ L.Draw.Feature.prototype.initialize.call(this, t, e))
210
+ },
211
+ addHooks: function () {
212
+ ;(L.Draw.Feature.prototype.addHooks.call(this),
213
+ this._map &&
214
+ ((this._markers = []),
215
+ (this._markerGroup = new L.LayerGroup()),
216
+ this._map.addLayer(this._markerGroup),
217
+ (this._poly = new L.Polyline([], this.options.shapeOptions)),
218
+ this._tooltip.updateContent(this._getTooltipText()),
219
+ this._mouseMarker ||
220
+ (this._mouseMarker = L.marker(this._map.getCenter(), {
221
+ icon: L.divIcon({
222
+ className: 'leaflet-mouse-marker',
223
+ iconAnchor: [20, 20],
224
+ iconSize: [40, 40]
225
+ }),
226
+ opacity: 0,
227
+ zIndexOffset: this.options.zIndexOffset
228
+ })),
229
+ this._mouseMarker
230
+ .on('mouseout', this._onMouseOut, this)
231
+ .on('mousemove', this._onMouseMove, this)
232
+ .on('mousedown', this._onMouseDown, this)
233
+ .on('mouseup', this._onMouseUp, this)
234
+ .addTo(this._map),
235
+ this._map
236
+ .on('mouseup', this._onMouseUp, this)
237
+ .on('mousemove', this._onMouseMove, this)
238
+ .on('zoomlevelschange', this._onZoomEnd, this)
239
+ .on('touchstart', this._onTouch, this)
240
+ .on('zoomend', this._onZoomEnd, this)))
241
+ },
242
+ removeHooks: function () {
243
+ ;(L.Draw.Feature.prototype.removeHooks.call(this),
244
+ this._clearHideErrorTimeout(),
245
+ this._cleanUpShape(),
246
+ this._map.removeLayer(this._markerGroup),
247
+ delete this._markerGroup,
248
+ delete this._markers,
249
+ this._map.removeLayer(this._poly),
250
+ delete this._poly,
251
+ this._mouseMarker
252
+ .off('mousedown', this._onMouseDown, this)
253
+ .off('mouseout', this._onMouseOut, this)
254
+ .off('mouseup', this._onMouseUp, this)
255
+ .off('mousemove', this._onMouseMove, this),
256
+ this._map.removeLayer(this._mouseMarker),
257
+ delete this._mouseMarker,
258
+ this._clearGuides(),
259
+ this._map
260
+ .off('mouseup', this._onMouseUp, this)
261
+ .off('mousemove', this._onMouseMove, this)
262
+ .off('zoomlevelschange', this._onZoomEnd, this)
263
+ .off('zoomend', this._onZoomEnd, this)
264
+ .off('touchstart', this._onTouch, this)
265
+ .off('click', this._onTouch, this))
266
+ },
267
+ deleteLastVertex: function () {
268
+ if (!(this._markers.length <= 1)) {
269
+ var t = this._markers.pop(),
270
+ e = this._poly,
271
+ i = e.getLatLngs(),
272
+ o = i.splice(-1, 1)[0]
273
+ ;(this._poly.setLatLngs(i),
274
+ this._markerGroup.removeLayer(t),
275
+ e.getLatLngs().length < 2 && this._map.removeLayer(e),
276
+ this._vertexChanged(o, !1))
277
+ }
278
+ },
279
+ addVertex: function (t) {
280
+ if (
281
+ this._markers.length >= 2 &&
282
+ !this.options.allowIntersection &&
283
+ this._poly.newLatLngIntersects(t)
284
+ )
285
+ return void this._showErrorTooltip()
286
+ ;(this._errorShown && this._hideErrorTooltip(),
287
+ this._markers.push(this._createMarker(t)),
288
+ this._poly.addLatLng(t),
289
+ 2 === this._poly.getLatLngs().length &&
290
+ this._map.addLayer(this._poly),
291
+ this._vertexChanged(t, !0))
292
+ },
293
+ completeShape: function () {
294
+ this._markers.length <= 1 ||
295
+ !this._shapeIsValid() ||
296
+ (this._fireCreatedEvent(),
297
+ this.disable(),
298
+ this.options.repeatMode && this.enable())
299
+ },
300
+ _finishShape: function () {
301
+ var t = this._poly._defaultShape
302
+ ? this._poly._defaultShape()
303
+ : this._poly.getLatLngs(),
304
+ e = this._poly.newLatLngIntersects(t[t.length - 1])
305
+ if ((!this.options.allowIntersection && e) || !this._shapeIsValid())
306
+ return void this._showErrorTooltip()
307
+ ;(this._fireCreatedEvent(),
308
+ this.disable(),
309
+ this.options.repeatMode && this.enable())
310
+ },
311
+ _shapeIsValid: function () {
312
+ return !0
313
+ },
314
+ _onZoomEnd: function () {
315
+ null !== this._markers && this._updateGuide()
316
+ },
317
+ _onMouseMove: function (t) {
318
+ var e = this._map.mouseEventToLayerPoint(t.originalEvent),
319
+ i = this._map.layerPointToLatLng(e)
320
+ ;((this._currentLatLng = i),
321
+ this._updateTooltip(i),
322
+ this._updateGuide(e),
323
+ this._mouseMarker.setLatLng(i),
324
+ L.DomEvent.preventDefault(t.originalEvent))
325
+ },
326
+ _vertexChanged: function (t, e) {
327
+ ;(this._map.fire(L.Draw.Event.DRAWVERTEX, {
328
+ layers: this._markerGroup
329
+ }),
330
+ this._updateFinishHandler(),
331
+ this._updateRunningMeasure(t, e),
332
+ this._clearGuides(),
333
+ this._updateTooltip())
334
+ },
335
+ _onMouseDown: function (t) {
336
+ if (
337
+ !this._clickHandled &&
338
+ !this._touchHandled &&
339
+ !this._disableMarkers
340
+ ) {
341
+ ;(this._onMouseMove(t),
342
+ (this._clickHandled = !0),
343
+ this._disableNewMarkers())
344
+ var e = t.originalEvent,
345
+ i = e.clientX,
346
+ o = e.clientY
347
+ this._startPoint.call(this, i, o)
348
+ }
349
+ },
350
+ _startPoint: function (t, e) {
351
+ this._mouseDownOrigin = L.point(t, e)
352
+ },
353
+ _onMouseUp: function (t) {
354
+ var e = t.originalEvent,
355
+ i = e.clientX,
356
+ o = e.clientY
357
+ ;(this._endPoint.call(this, i, o, t), (this._clickHandled = null))
358
+ },
359
+ _endPoint: function (e, i, o) {
360
+ if (this._mouseDownOrigin) {
361
+ var a = L.point(e, i).distanceTo(this._mouseDownOrigin),
362
+ n = this._calculateFinishDistance(o.latlng)
363
+ ;(this.options.maxPoints > 1 &&
364
+ this.options.maxPoints == this._markers.length + 1
365
+ ? (this.addVertex(o.latlng), this._finishShape())
366
+ : n < 10 && L.Browser.touch
367
+ ? this._finishShape()
368
+ : Math.abs(a) < 9 * (t.devicePixelRatio || 1) &&
369
+ this.addVertex(o.latlng),
370
+ this._enableNewMarkers())
371
+ }
372
+ this._mouseDownOrigin = null
373
+ },
374
+ _onTouch: function (t) {
375
+ var e,
376
+ i,
377
+ o = t.originalEvent
378
+ ;(!o.touches ||
379
+ !o.touches[0] ||
380
+ this._clickHandled ||
381
+ this._touchHandled ||
382
+ this._disableMarkers ||
383
+ ((e = o.touches[0].clientX),
384
+ (i = o.touches[0].clientY),
385
+ this._disableNewMarkers(),
386
+ (this._touchHandled = !0),
387
+ this._startPoint.call(this, e, i),
388
+ this._endPoint.call(this, e, i, t),
389
+ (this._touchHandled = null)),
390
+ (this._clickHandled = null))
391
+ },
392
+ _onMouseOut: function () {
393
+ this._tooltip && this._tooltip._onMouseOut.call(this._tooltip)
394
+ },
395
+ _calculateFinishDistance: function (t) {
396
+ var e
397
+ if (this._markers.length > 0) {
398
+ var i
399
+ if (this.type === L.Draw.Polyline.TYPE)
400
+ i = this._markers[this._markers.length - 1]
401
+ else {
402
+ if (this.type !== L.Draw.Polygon.TYPE) return 1 / 0
403
+ i = this._markers[0]
404
+ }
405
+ var o = this._map.latLngToContainerPoint(i.getLatLng()),
406
+ a = new L.Marker(t, {
407
+ icon: this.options.icon,
408
+ zIndexOffset: 2 * this.options.zIndexOffset
409
+ }),
410
+ n = this._map.latLngToContainerPoint(a.getLatLng())
411
+ e = o.distanceTo(n)
412
+ } else e = 1 / 0
413
+ return e
414
+ },
415
+ _updateFinishHandler: function () {
416
+ var t = this._markers.length
417
+ ;(t > 1 && this._markers[t - 1].on('click', this._finishShape, this),
418
+ t > 2 && this._markers[t - 2].off('click', this._finishShape, this))
419
+ },
420
+ _createMarker: function (t) {
421
+ var e = new L.Marker(t, {
422
+ icon: this.options.icon,
423
+ zIndexOffset: 2 * this.options.zIndexOffset
424
+ })
425
+ return (this._markerGroup.addLayer(e), e)
426
+ },
427
+ _updateGuide: function (t) {
428
+ var e = this._markers ? this._markers.length : 0
429
+ e > 0 &&
430
+ ((t = t || this._map.latLngToLayerPoint(this._currentLatLng)),
431
+ this._clearGuides(),
432
+ this._drawGuide(
433
+ this._map.latLngToLayerPoint(this._markers[e - 1].getLatLng()),
434
+ t
435
+ ))
436
+ },
437
+ _updateTooltip: function (t) {
438
+ var e = this._getTooltipText()
439
+ ;(t && this._tooltip.updatePosition(t),
440
+ this._errorShown || this._tooltip.updateContent(e))
441
+ },
442
+ _drawGuide: function (t, e) {
443
+ var i,
444
+ o,
445
+ a,
446
+ n = Math.floor(
447
+ Math.sqrt(Math.pow(e.x - t.x, 2) + Math.pow(e.y - t.y, 2))
448
+ ),
449
+ s = this.options.guidelineDistance,
450
+ r = this.options.maxGuideLineLength,
451
+ l = n > r ? n - r : s
452
+ for (
453
+ this._guidesContainer ||
454
+ (this._guidesContainer = L.DomUtil.create(
455
+ 'div',
456
+ 'leaflet-draw-guides',
457
+ this._overlayPane
458
+ ));
459
+ l < n;
460
+ l += this.options.guidelineDistance
461
+ )
462
+ ((i = l / n),
463
+ (o = {
464
+ x: Math.floor(t.x * (1 - i) + i * e.x),
465
+ y: Math.floor(t.y * (1 - i) + i * e.y)
466
+ }),
467
+ (a = L.DomUtil.create(
468
+ 'div',
469
+ 'leaflet-draw-guide-dash',
470
+ this._guidesContainer
471
+ )),
472
+ (a.style.backgroundColor = this._errorShown
473
+ ? this.options.drawError.color
474
+ : this.options.shapeOptions.color),
475
+ L.DomUtil.setPosition(a, o))
476
+ },
477
+ _updateGuideColor: function (t) {
478
+ if (this._guidesContainer)
479
+ for (
480
+ var e = 0, i = this._guidesContainer.childNodes.length;
481
+ e < i;
482
+ e++
483
+ )
484
+ this._guidesContainer.childNodes[e].style.backgroundColor = t
485
+ },
486
+ _clearGuides: function () {
487
+ if (this._guidesContainer)
488
+ for (; this._guidesContainer.firstChild; )
489
+ this._guidesContainer.removeChild(this._guidesContainer.firstChild)
490
+ },
491
+ _getTooltipText: function () {
492
+ var t,
493
+ e,
494
+ i = this.options.showLength
495
+ return (
496
+ 0 === this._markers.length
497
+ ? (t = { text: L.drawLocal.draw.handlers.polyline.tooltip.start })
498
+ : ((e = i ? this._getMeasurementString() : ''),
499
+ (t =
500
+ 1 === this._markers.length
501
+ ? {
502
+ text: L.drawLocal.draw.handlers.polyline.tooltip.cont,
503
+ subtext: e
504
+ }
505
+ : {
506
+ text: L.drawLocal.draw.handlers.polyline.tooltip.end,
507
+ subtext: e
508
+ })),
509
+ t
510
+ )
511
+ },
512
+ _updateRunningMeasure: function (t, e) {
513
+ var i,
514
+ o,
515
+ a = this._markers.length
516
+ 1 === this._markers.length
517
+ ? (this._measurementRunningTotal = 0)
518
+ : ((i = a - (e ? 2 : 1)),
519
+ (o = L.GeometryUtil.isVersion07x()
520
+ ? t.distanceTo(this._markers[i].getLatLng()) *
521
+ (this.options.factor || 1)
522
+ : this._map.distance(t, this._markers[i].getLatLng()) *
523
+ (this.options.factor || 1)),
524
+ (this._measurementRunningTotal += o * (e ? 1 : -1)))
525
+ },
526
+ _getMeasurementString: function () {
527
+ var t,
528
+ e = this._currentLatLng,
529
+ i = this._markers[this._markers.length - 1].getLatLng()
530
+ return (
531
+ (t = L.GeometryUtil.isVersion07x()
532
+ ? i && e && e.distanceTo
533
+ ? this._measurementRunningTotal +
534
+ e.distanceTo(i) * (this.options.factor || 1)
535
+ : this._measurementRunningTotal || 0
536
+ : i && e
537
+ ? this._measurementRunningTotal +
538
+ this._map.distance(e, i) * (this.options.factor || 1)
539
+ : this._measurementRunningTotal || 0),
540
+ L.GeometryUtil.readableDistance(
541
+ t,
542
+ this.options.metric,
543
+ this.options.feet,
544
+ this.options.nautic,
545
+ this.options.precision
546
+ )
547
+ )
548
+ },
549
+ _showErrorTooltip: function () {
550
+ ;((this._errorShown = !0),
551
+ this._tooltip
552
+ .showAsError()
553
+ .updateContent({ text: this.options.drawError.message }),
554
+ this._updateGuideColor(this.options.drawError.color),
555
+ this._poly.setStyle({ color: this.options.drawError.color }),
556
+ this._clearHideErrorTimeout(),
557
+ (this._hideErrorTimeout = setTimeout(
558
+ L.Util.bind(this._hideErrorTooltip, this),
559
+ this.options.drawError.timeout
560
+ )))
561
+ },
562
+ _hideErrorTooltip: function () {
563
+ ;((this._errorShown = !1),
564
+ this._clearHideErrorTimeout(),
565
+ this._tooltip.removeError().updateContent(this._getTooltipText()),
566
+ this._updateGuideColor(this.options.shapeOptions.color),
567
+ this._poly.setStyle({ color: this.options.shapeOptions.color }))
568
+ },
569
+ _clearHideErrorTimeout: function () {
570
+ this._hideErrorTimeout &&
571
+ (clearTimeout(this._hideErrorTimeout),
572
+ (this._hideErrorTimeout = null))
573
+ },
574
+ _disableNewMarkers: function () {
575
+ this._disableMarkers = !0
576
+ },
577
+ _enableNewMarkers: function () {
578
+ setTimeout(
579
+ function () {
580
+ this._disableMarkers = !1
581
+ }.bind(this),
582
+ 50
583
+ )
584
+ },
585
+ _cleanUpShape: function () {
586
+ this._markers.length > 1 &&
587
+ this._markers[this._markers.length - 1].off(
588
+ 'click',
589
+ this._finishShape,
590
+ this
591
+ )
592
+ },
593
+ _fireCreatedEvent: function () {
594
+ var t = new this.Poly(
595
+ this._poly.getLatLngs(),
596
+ this.options.shapeOptions
597
+ )
598
+ L.Draw.Feature.prototype._fireCreatedEvent.call(this, t)
599
+ }
600
+ })),
601
+ (L.Draw.Polygon = L.Draw.Polyline.extend({
602
+ statics: { TYPE: 'polygon' },
603
+ Poly: L.Polygon,
604
+ options: {
605
+ showArea: !1,
606
+ showLength: !1,
607
+ shapeOptions: {
608
+ stroke: !0,
609
+ color: '#3388ff',
610
+ weight: 4,
611
+ opacity: 0.5,
612
+ fill: !0,
613
+ fillColor: null,
614
+ fillOpacity: 0.2,
615
+ clickable: !0
616
+ },
617
+ metric: !0,
618
+ feet: !0,
619
+ nautic: !1,
620
+ precision: {}
621
+ },
622
+ initialize: function (t, e) {
623
+ ;(L.Draw.Polyline.prototype.initialize.call(this, t, e),
624
+ (this.type = L.Draw.Polygon.TYPE))
625
+ },
626
+ _updateFinishHandler: function () {
627
+ var t = this._markers.length
628
+ ;(1 === t && this._markers[0].on('click', this._finishShape, this),
629
+ t > 2 &&
630
+ (this._markers[t - 1].on('dblclick', this._finishShape, this),
631
+ t > 3 &&
632
+ this._markers[t - 2].off('dblclick', this._finishShape, this)))
633
+ },
634
+ _getTooltipText: function () {
635
+ var t, e
636
+ return (
637
+ 0 === this._markers.length
638
+ ? (t = L.drawLocal.draw.handlers.polygon.tooltip.start)
639
+ : this._markers.length < 3
640
+ ? ((t = L.drawLocal.draw.handlers.polygon.tooltip.cont),
641
+ (e = this._getMeasurementString()))
642
+ : ((t = L.drawLocal.draw.handlers.polygon.tooltip.end),
643
+ (e = this._getMeasurementString())),
644
+ { text: t, subtext: e }
645
+ )
646
+ },
647
+ _getMeasurementString: function () {
648
+ var t = this._area,
649
+ e = ''
650
+ return t || this.options.showLength
651
+ ? (this.options.showLength &&
652
+ (e = L.Draw.Polyline.prototype._getMeasurementString.call(this)),
653
+ t &&
654
+ (e +=
655
+ '<br>' +
656
+ L.GeometryUtil.readableArea(
657
+ t,
658
+ this.options.metric,
659
+ this.options.precision
660
+ )),
661
+ e)
662
+ : null
663
+ },
664
+ _shapeIsValid: function () {
665
+ return this._markers.length >= 3
666
+ },
667
+ _vertexChanged: function (t, e) {
668
+ var i
669
+ ;(!this.options.allowIntersection &&
670
+ this.options.showArea &&
671
+ ((i = this._poly.getLatLngs()),
672
+ (this._area = L.GeometryUtil.geodesicArea(i))),
673
+ L.Draw.Polyline.prototype._vertexChanged.call(this, t, e))
674
+ },
675
+ _cleanUpShape: function () {
676
+ var t = this._markers.length
677
+ t > 0 &&
678
+ (this._markers[0].off('click', this._finishShape, this),
679
+ t > 2 &&
680
+ this._markers[t - 1].off('dblclick', this._finishShape, this))
681
+ }
682
+ })),
683
+ (L.SimpleShape = {}),
684
+ (L.Draw.SimpleShape = L.Draw.Feature.extend({
685
+ options: { repeatMode: !1 },
686
+ initialize: function (t, e) {
687
+ ;((this._endLabelText =
688
+ L.drawLocal.draw.handlers.simpleshape.tooltip.end),
689
+ L.Draw.Feature.prototype.initialize.call(this, t, e))
690
+ },
691
+ addHooks: function () {
692
+ ;(L.Draw.Feature.prototype.addHooks.call(this),
693
+ this._map &&
694
+ ((this._mapDraggable = this._map.dragging.enabled()),
695
+ this._mapDraggable && this._map.dragging.disable(),
696
+ (this._container.style.cursor = 'crosshair'),
697
+ this._tooltip.updateContent({ text: this._initialLabelText }),
698
+ this._map
699
+ .on('mousedown', this._onMouseDown, this)
700
+ .on('mousemove', this._onMouseMove, this)
701
+ .on('touchstart', this._onMouseDown, this)
702
+ .on('touchmove', this._onMouseMove, this),
703
+ e.addEventListener('touchstart', L.DomEvent.preventDefault, {
704
+ passive: !1
705
+ })))
706
+ },
707
+ removeHooks: function () {
708
+ ;(L.Draw.Feature.prototype.removeHooks.call(this),
709
+ this._map &&
710
+ (this._mapDraggable && this._map.dragging.enable(),
711
+ (this._container.style.cursor = ''),
712
+ this._map
713
+ .off('mousedown', this._onMouseDown, this)
714
+ .off('mousemove', this._onMouseMove, this)
715
+ .off('touchstart', this._onMouseDown, this)
716
+ .off('touchmove', this._onMouseMove, this),
717
+ L.DomEvent.off(e, 'mouseup', this._onMouseUp, this),
718
+ L.DomEvent.off(e, 'touchend', this._onMouseUp, this),
719
+ e.removeEventListener('touchstart', L.DomEvent.preventDefault),
720
+ this._shape &&
721
+ (this._map.removeLayer(this._shape), delete this._shape)),
722
+ (this._isDrawing = !1))
723
+ },
724
+ _getTooltipText: function () {
725
+ return { text: this._endLabelText }
726
+ },
727
+ _onMouseDown: function (t) {
728
+ ;((this._isDrawing = !0),
729
+ (this._startLatLng = t.latlng),
730
+ L.DomEvent.on(e, 'mouseup', this._onMouseUp, this)
731
+ .on(e, 'touchend', this._onMouseUp, this)
732
+ .preventDefault(t.originalEvent))
733
+ },
734
+ _onMouseMove: function (t) {
735
+ var e = t.latlng
736
+ ;(this._tooltip.updatePosition(e),
737
+ this._isDrawing &&
738
+ (this._tooltip.updateContent(this._getTooltipText()),
739
+ this._drawShape(e)))
740
+ },
741
+ _onMouseUp: function () {
742
+ ;(this._shape && this._fireCreatedEvent(),
743
+ this.disable(),
744
+ this.options.repeatMode && this.enable())
745
+ }
746
+ })),
747
+ (L.Draw.Rectangle = L.Draw.SimpleShape.extend({
748
+ statics: { TYPE: 'rectangle' },
749
+ options: {
750
+ shapeOptions: {
751
+ stroke: !0,
752
+ color: '#3388ff',
753
+ weight: 4,
754
+ opacity: 0.5,
755
+ fill: !0,
756
+ fillColor: null,
757
+ fillOpacity: 0.2,
758
+ clickable: !0
759
+ },
760
+ showArea: !0,
761
+ metric: !0
762
+ },
763
+ initialize: function (t, e) {
764
+ ;((this.type = L.Draw.Rectangle.TYPE),
765
+ (this._initialLabelText =
766
+ L.drawLocal.draw.handlers.rectangle.tooltip.start),
767
+ L.Draw.SimpleShape.prototype.initialize.call(this, t, e))
768
+ },
769
+ disable: function () {
770
+ this._enabled &&
771
+ ((this._isCurrentlyTwoClickDrawing = !1),
772
+ L.Draw.SimpleShape.prototype.disable.call(this))
773
+ },
774
+ _onMouseUp: function (t) {
775
+ if (!this._shape && !this._isCurrentlyTwoClickDrawing)
776
+ return void (this._isCurrentlyTwoClickDrawing = !0)
777
+ ;(this._isCurrentlyTwoClickDrawing && !o(t.target, 'leaflet-pane')) ||
778
+ L.Draw.SimpleShape.prototype._onMouseUp.call(this)
779
+ },
780
+ _drawShape: function (t) {
781
+ this._shape
782
+ ? this._shape.setBounds(new L.LatLngBounds(this._startLatLng, t))
783
+ : ((this._shape = new L.Rectangle(
784
+ new L.LatLngBounds(this._startLatLng, t),
785
+ this.options.shapeOptions
786
+ )),
787
+ this._map.addLayer(this._shape))
788
+ },
789
+ _fireCreatedEvent: function () {
790
+ var t = new L.Rectangle(
791
+ this._shape.getBounds(),
792
+ this.options.shapeOptions
793
+ )
794
+ L.Draw.SimpleShape.prototype._fireCreatedEvent.call(this, t)
795
+ },
796
+ _getTooltipText: function () {
797
+ var t,
798
+ e,
799
+ i,
800
+ o = L.Draw.SimpleShape.prototype._getTooltipText.call(this),
801
+ a = this._shape,
802
+ n = this.options.showArea
803
+ return (
804
+ a &&
805
+ ((t = this._shape._defaultShape
806
+ ? this._shape._defaultShape()
807
+ : this._shape.getLatLngs()),
808
+ (e = L.GeometryUtil.geodesicArea(t)),
809
+ (i = n ? L.GeometryUtil.readableArea(e, this.options.metric) : '')),
810
+ { text: o.text, subtext: i }
811
+ )
812
+ }
813
+ })),
814
+ (L.Draw.Marker = L.Draw.Feature.extend({
815
+ statics: { TYPE: 'marker' },
816
+ options: {
817
+ icon: new L.Icon.Default(),
818
+ repeatMode: !1,
819
+ zIndexOffset: 2e3
820
+ },
821
+ initialize: function (t, e) {
822
+ ;((this.type = L.Draw.Marker.TYPE),
823
+ (this._initialLabelText =
824
+ L.drawLocal.draw.handlers.marker.tooltip.start),
825
+ L.Draw.Feature.prototype.initialize.call(this, t, e))
826
+ },
827
+ addHooks: function () {
828
+ ;(L.Draw.Feature.prototype.addHooks.call(this),
829
+ this._map &&
830
+ (this._tooltip.updateContent({ text: this._initialLabelText }),
831
+ this._mouseMarker ||
832
+ (this._mouseMarker = L.marker(this._map.getCenter(), {
833
+ icon: L.divIcon({
834
+ className: 'leaflet-mouse-marker',
835
+ iconAnchor: [20, 20],
836
+ iconSize: [40, 40]
837
+ }),
838
+ opacity: 0,
839
+ zIndexOffset: this.options.zIndexOffset
840
+ })),
841
+ this._mouseMarker.on('click', this._onClick, this).addTo(this._map),
842
+ this._map.on('mousemove', this._onMouseMove, this),
843
+ this._map.on('click', this._onTouch, this)))
844
+ },
845
+ removeHooks: function () {
846
+ ;(L.Draw.Feature.prototype.removeHooks.call(this),
847
+ this._map &&
848
+ (this._map
849
+ .off('click', this._onClick, this)
850
+ .off('click', this._onTouch, this),
851
+ this._marker &&
852
+ (this._marker.off('click', this._onClick, this),
853
+ this._map.removeLayer(this._marker),
854
+ delete this._marker),
855
+ this._mouseMarker.off('click', this._onClick, this),
856
+ this._map.removeLayer(this._mouseMarker),
857
+ delete this._mouseMarker,
858
+ this._map.off('mousemove', this._onMouseMove, this)))
859
+ },
860
+ _onMouseMove: function (t) {
861
+ var e = t.latlng
862
+ ;(this._tooltip.updatePosition(e),
863
+ this._mouseMarker.setLatLng(e),
864
+ this._marker
865
+ ? ((e = this._mouseMarker.getLatLng()), this._marker.setLatLng(e))
866
+ : ((this._marker = this._createMarker(e)),
867
+ this._marker.on('click', this._onClick, this),
868
+ this._map
869
+ .on('click', this._onClick, this)
870
+ .addLayer(this._marker)))
871
+ },
872
+ _createMarker: function (t) {
873
+ return new L.Marker(t, {
874
+ icon: this.options.icon,
875
+ zIndexOffset: this.options.zIndexOffset
876
+ })
877
+ },
878
+ _onClick: function () {
879
+ ;(this._fireCreatedEvent(),
880
+ this.disable(),
881
+ this.options.repeatMode && this.enable())
882
+ },
883
+ _onTouch: function (t) {
884
+ ;(this._onMouseMove(t), this._onClick())
885
+ },
886
+ _fireCreatedEvent: function () {
887
+ var t = new L.Marker.Touch(this._marker.getLatLng(), {
888
+ icon: this.options.icon
889
+ })
890
+ L.Draw.Feature.prototype._fireCreatedEvent.call(this, t)
891
+ }
892
+ })),
893
+ (L.Draw.CircleMarker = L.Draw.Marker.extend({
894
+ statics: { TYPE: 'circlemarker' },
895
+ options: {
896
+ stroke: !0,
897
+ color: '#3388ff',
898
+ weight: 4,
899
+ opacity: 0.5,
900
+ fill: !0,
901
+ fillColor: null,
902
+ fillOpacity: 0.2,
903
+ clickable: !0,
904
+ zIndexOffset: 2e3
905
+ },
906
+ initialize: function (t, e) {
907
+ ;((this.type = L.Draw.CircleMarker.TYPE),
908
+ (this._initialLabelText =
909
+ L.drawLocal.draw.handlers.circlemarker.tooltip.start),
910
+ L.Draw.Feature.prototype.initialize.call(this, t, e))
911
+ },
912
+ _fireCreatedEvent: function () {
913
+ var t = new L.CircleMarker(this._marker.getLatLng(), this.options)
914
+ L.Draw.Feature.prototype._fireCreatedEvent.call(this, t)
915
+ },
916
+ _createMarker: function (t) {
917
+ return new L.CircleMarker(t, this.options)
918
+ }
919
+ })),
920
+ (L.Draw.Circle = L.Draw.SimpleShape.extend({
921
+ statics: { TYPE: 'circle' },
922
+ options: {
923
+ shapeOptions: {
924
+ stroke: !0,
925
+ color: '#3388ff',
926
+ weight: 4,
927
+ opacity: 0.5,
928
+ fill: !0,
929
+ fillColor: null,
930
+ fillOpacity: 0.2,
931
+ clickable: !0
932
+ },
933
+ showRadius: !0,
934
+ metric: !0,
935
+ feet: !0,
936
+ nautic: !1
937
+ },
938
+ initialize: function (t, e) {
939
+ ;((this.type = L.Draw.Circle.TYPE),
940
+ (this._initialLabelText =
941
+ L.drawLocal.draw.handlers.circle.tooltip.start),
942
+ L.Draw.SimpleShape.prototype.initialize.call(this, t, e))
943
+ },
944
+ _drawShape: function (t) {
945
+ if (L.GeometryUtil.isVersion07x())
946
+ var e = this._startLatLng.distanceTo(t)
947
+ else var e = this._map.distance(this._startLatLng, t)
948
+ this._shape
949
+ ? this._shape.setRadius(e)
950
+ : ((this._shape = new L.Circle(
951
+ this._startLatLng,
952
+ e,
953
+ this.options.shapeOptions
954
+ )),
955
+ this._map.addLayer(this._shape))
956
+ },
957
+ _fireCreatedEvent: function () {
958
+ var t = new L.Circle(
959
+ this._startLatLng,
960
+ this._shape.getRadius(),
961
+ this.options.shapeOptions
962
+ )
963
+ L.Draw.SimpleShape.prototype._fireCreatedEvent.call(this, t)
964
+ },
965
+ _onMouseMove: function (t) {
966
+ var e,
967
+ i = t.latlng,
968
+ o = this.options.showRadius,
969
+ a = this.options.metric
970
+ if ((this._tooltip.updatePosition(i), this._isDrawing)) {
971
+ ;(this._drawShape(i), (e = this._shape.getRadius().toFixed(1)))
972
+ var n = ''
973
+ ;(o &&
974
+ (n =
975
+ L.drawLocal.draw.handlers.circle.radius +
976
+ ': ' +
977
+ L.GeometryUtil.readableDistance(
978
+ e,
979
+ a,
980
+ this.options.feet,
981
+ this.options.nautic
982
+ )),
983
+ this._tooltip.updateContent({
984
+ text: this._endLabelText,
985
+ subtext: n
986
+ }))
987
+ }
988
+ }
989
+ })),
990
+ (L.Edit = L.Edit || {}),
991
+ (L.Edit.Marker = L.Handler.extend({
992
+ initialize: function (t, e) {
993
+ ;((this._marker = t), L.setOptions(this, e))
994
+ },
995
+ addHooks: function () {
996
+ var t = this._marker
997
+ ;(t.dragging.enable(),
998
+ t.on('dragend', this._onDragEnd, t),
999
+ this._toggleMarkerHighlight())
1000
+ },
1001
+ removeHooks: function () {
1002
+ var t = this._marker
1003
+ ;(t.dragging.disable(),
1004
+ t.off('dragend', this._onDragEnd, t),
1005
+ this._toggleMarkerHighlight())
1006
+ },
1007
+ _onDragEnd: function (t) {
1008
+ var e = t.target
1009
+ ;((e.edited = !0), this._map.fire(L.Draw.Event.EDITMOVE, { layer: e }))
1010
+ },
1011
+ _toggleMarkerHighlight: function () {
1012
+ var t = this._marker._icon
1013
+ t &&
1014
+ ((t.style.display = 'none'),
1015
+ L.DomUtil.hasClass(t, 'leaflet-edit-marker-selected')
1016
+ ? (L.DomUtil.removeClass(t, 'leaflet-edit-marker-selected'),
1017
+ this._offsetMarker(t, -4))
1018
+ : (L.DomUtil.addClass(t, 'leaflet-edit-marker-selected'),
1019
+ this._offsetMarker(t, 4)),
1020
+ (t.style.display = ''))
1021
+ },
1022
+ _offsetMarker: function (t, e) {
1023
+ var i = parseInt(t.style.marginTop, 10) - e,
1024
+ o = parseInt(t.style.marginLeft, 10) - e
1025
+ ;((t.style.marginTop = i + 'px'), (t.style.marginLeft = o + 'px'))
1026
+ }
1027
+ })),
1028
+ L.Marker.addInitHook(function () {
1029
+ L.Edit.Marker &&
1030
+ ((this.editing = new L.Edit.Marker(this)),
1031
+ this.options.editable && this.editing.enable())
1032
+ }),
1033
+ (L.Edit = L.Edit || {}),
1034
+ (L.Edit.Poly = L.Handler.extend({
1035
+ initialize: function (t) {
1036
+ ;((this.latlngs = [t._latlngs]),
1037
+ t._holes && (this.latlngs = this.latlngs.concat(t._holes)),
1038
+ (this._poly = t),
1039
+ this._poly.on('revert-edited', this._updateLatLngs, this))
1040
+ },
1041
+ _defaultShape: function () {
1042
+ return L.Polyline._flat
1043
+ ? L.Polyline._flat(this._poly._latlngs)
1044
+ ? this._poly._latlngs
1045
+ : this._poly._latlngs[0]
1046
+ : this._poly._latlngs
1047
+ },
1048
+ _eachVertexHandler: function (t) {
1049
+ for (var e = 0; e < this._verticesHandlers.length; e++)
1050
+ t(this._verticesHandlers[e])
1051
+ },
1052
+ addHooks: function () {
1053
+ ;(this._initHandlers(),
1054
+ this._eachVertexHandler(function (t) {
1055
+ t.addHooks()
1056
+ }))
1057
+ },
1058
+ removeHooks: function () {
1059
+ this._eachVertexHandler(function (t) {
1060
+ t.removeHooks()
1061
+ })
1062
+ },
1063
+ updateMarkers: function () {
1064
+ this._eachVertexHandler(function (t) {
1065
+ t.updateMarkers()
1066
+ })
1067
+ },
1068
+ _initHandlers: function () {
1069
+ this._verticesHandlers = []
1070
+ for (var t = 0; t < this.latlngs.length; t++)
1071
+ this._verticesHandlers.push(
1072
+ new L.Edit.PolyVerticesEdit(
1073
+ this._poly,
1074
+ this.latlngs[t],
1075
+ this._poly.options.poly
1076
+ )
1077
+ )
1078
+ },
1079
+ _updateLatLngs: function (t) {
1080
+ ;((this.latlngs = [t.layer._latlngs]),
1081
+ t.layer._holes &&
1082
+ (this.latlngs = this.latlngs.concat(t.layer._holes)))
1083
+ }
1084
+ })),
1085
+ (L.Edit.PolyVerticesEdit = L.Handler.extend({
1086
+ options: {
1087
+ icon: new L.DivIcon({
1088
+ iconSize: new L.Point(8, 8),
1089
+ className: 'leaflet-div-icon leaflet-editing-icon'
1090
+ }),
1091
+ touchIcon: new L.DivIcon({
1092
+ iconSize: new L.Point(20, 20),
1093
+ className: 'leaflet-div-icon leaflet-editing-icon leaflet-touch-icon'
1094
+ }),
1095
+ drawError: { color: '#b00b00', timeout: 1e3 }
1096
+ },
1097
+ initialize: function (t, e, i) {
1098
+ ;(L.Browser.touch && (this.options.icon = this.options.touchIcon),
1099
+ (this._poly = t),
1100
+ i &&
1101
+ i.drawError &&
1102
+ (i.drawError = L.Util.extend(
1103
+ {},
1104
+ this.options.drawError,
1105
+ i.drawError
1106
+ )),
1107
+ (this._latlngs = e),
1108
+ L.setOptions(this, i))
1109
+ },
1110
+ _defaultShape: function () {
1111
+ return L.Polyline._flat
1112
+ ? L.Polyline._flat(this._latlngs)
1113
+ ? this._latlngs
1114
+ : this._latlngs[0]
1115
+ : this._latlngs
1116
+ },
1117
+ addHooks: function () {
1118
+ var t = this._poly,
1119
+ e = t._path
1120
+ ;(t instanceof L.Polygon ||
1121
+ ((t.options.fill = !1),
1122
+ t.options.editing && (t.options.editing.fill = !1)),
1123
+ e &&
1124
+ t.options.editing &&
1125
+ t.options.editing.className &&
1126
+ (t.options.original.className &&
1127
+ t.options.original.className.split(' ').forEach(function (t) {
1128
+ L.DomUtil.removeClass(e, t)
1129
+ }),
1130
+ t.options.editing.className.split(' ').forEach(function (t) {
1131
+ L.DomUtil.addClass(e, t)
1132
+ })),
1133
+ t.setStyle(t.options.editing),
1134
+ this._poly._map &&
1135
+ ((this._map = this._poly._map),
1136
+ this._markerGroup || this._initMarkers(),
1137
+ this._poly._map.addLayer(this._markerGroup)))
1138
+ },
1139
+ removeHooks: function () {
1140
+ var t = this._poly,
1141
+ e = t._path
1142
+ ;(e &&
1143
+ t.options.editing &&
1144
+ t.options.editing.className &&
1145
+ (t.options.editing.className.split(' ').forEach(function (t) {
1146
+ L.DomUtil.removeClass(e, t)
1147
+ }),
1148
+ t.options.original.className &&
1149
+ t.options.original.className.split(' ').forEach(function (t) {
1150
+ L.DomUtil.addClass(e, t)
1151
+ })),
1152
+ t.setStyle(t.options.original),
1153
+ t._map &&
1154
+ (t._map.removeLayer(this._markerGroup),
1155
+ delete this._markerGroup,
1156
+ delete this._markers))
1157
+ },
1158
+ updateMarkers: function () {
1159
+ ;(this._markerGroup.clearLayers(), this._initMarkers())
1160
+ },
1161
+ _initMarkers: function () {
1162
+ ;(this._markerGroup || (this._markerGroup = new L.LayerGroup()),
1163
+ (this._markers = []))
1164
+ var t,
1165
+ e,
1166
+ i,
1167
+ o,
1168
+ a = this._defaultShape()
1169
+ for (t = 0, i = a.length; t < i; t++)
1170
+ ((o = this._createMarker(a[t], t)),
1171
+ o.on('click', this._onMarkerClick, this),
1172
+ o.on('contextmenu', this._onContextMenu, this),
1173
+ this._markers.push(o))
1174
+ var n, s
1175
+ for (t = 0, e = i - 1; t < i; e = t++)
1176
+ (0 !== t || (L.Polygon && this._poly instanceof L.Polygon)) &&
1177
+ ((n = this._markers[e]),
1178
+ (s = this._markers[t]),
1179
+ this._createMiddleMarker(n, s),
1180
+ this._updatePrevNext(n, s))
1181
+ },
1182
+ _createMarker: function (t, e) {
1183
+ var i = new L.Marker.Touch(t, {
1184
+ draggable: !0,
1185
+ icon: this.options.icon
1186
+ })
1187
+ return (
1188
+ (i._origLatLng = t),
1189
+ (i._index = e),
1190
+ i
1191
+ .on('dragstart', this._onMarkerDragStart, this)
1192
+ .on('drag', this._onMarkerDrag, this)
1193
+ .on('dragend', this._fireEdit, this)
1194
+ .on('touchmove', this._onTouchMove, this)
1195
+ .on('touchend', this._fireEdit, this)
1196
+ .on('MSPointerMove', this._onTouchMove, this)
1197
+ .on('MSPointerUp', this._fireEdit, this),
1198
+ this._markerGroup.addLayer(i),
1199
+ i
1200
+ )
1201
+ },
1202
+ _onMarkerDragStart: function () {
1203
+ this._poly.fire('editstart')
1204
+ },
1205
+ _spliceLatLngs: function () {
1206
+ var t = this._defaultShape(),
1207
+ e = [].splice.apply(t, arguments)
1208
+ return (this._poly._convertLatLngs(t, !0), this._poly.redraw(), e)
1209
+ },
1210
+ _removeMarker: function (t) {
1211
+ var e = t._index
1212
+ ;(this._markerGroup.removeLayer(t),
1213
+ this._markers.splice(e, 1),
1214
+ this._spliceLatLngs(e, 1),
1215
+ this._updateIndexes(e, -1),
1216
+ t
1217
+ .off('dragstart', this._onMarkerDragStart, this)
1218
+ .off('drag', this._onMarkerDrag, this)
1219
+ .off('dragend', this._fireEdit, this)
1220
+ .off('touchmove', this._onMarkerDrag, this)
1221
+ .off('touchend', this._fireEdit, this)
1222
+ .off('click', this._onMarkerClick, this)
1223
+ .off('MSPointerMove', this._onTouchMove, this)
1224
+ .off('MSPointerUp', this._fireEdit, this))
1225
+ },
1226
+ _fireEdit: function () {
1227
+ ;((this._poly.edited = !0),
1228
+ this._poly.fire('edit'),
1229
+ this._poly._map.fire(L.Draw.Event.EDITVERTEX, {
1230
+ layers: this._markerGroup,
1231
+ poly: this._poly
1232
+ }))
1233
+ },
1234
+ _onMarkerDrag: function (t) {
1235
+ var e = t.target,
1236
+ i = this._poly,
1237
+ o = L.LatLngUtil.cloneLatLng(e._origLatLng)
1238
+ if ((L.extend(e._origLatLng, e._latlng), i.options.poly)) {
1239
+ var a = i._map._editTooltip
1240
+ if (!i.options.poly.allowIntersection && i.intersects()) {
1241
+ ;(L.extend(e._origLatLng, o), e.setLatLng(o))
1242
+ var n = i.options.color
1243
+ ;(i.setStyle({ color: this.options.drawError.color }),
1244
+ a &&
1245
+ a.updateContent({
1246
+ text: L.drawLocal.draw.handlers.polyline.error
1247
+ }),
1248
+ setTimeout(function () {
1249
+ ;(i.setStyle({ color: n }),
1250
+ a &&
1251
+ a.updateContent({
1252
+ text: L.drawLocal.edit.handlers.edit.tooltip.text,
1253
+ subtext: L.drawLocal.edit.handlers.edit.tooltip.subtext
1254
+ }))
1255
+ }, 1e3))
1256
+ }
1257
+ }
1258
+ ;(e._middleLeft &&
1259
+ e._middleLeft.setLatLng(this._getMiddleLatLng(e._prev, e)),
1260
+ e._middleRight &&
1261
+ e._middleRight.setLatLng(this._getMiddleLatLng(e, e._next)),
1262
+ (this._poly._bounds._southWest = L.latLng(1 / 0, 1 / 0)),
1263
+ (this._poly._bounds._northEast = L.latLng(-1 / 0, -1 / 0)))
1264
+ var s = this._poly.getLatLngs()
1265
+ ;(this._poly._convertLatLngs(s, !0),
1266
+ this._poly.redraw(),
1267
+ this._poly.fire('editdrag'))
1268
+ },
1269
+ _onMarkerClick: function (t) {
1270
+ var e = L.Polygon && this._poly instanceof L.Polygon ? 4 : 3,
1271
+ i = t.target
1272
+ this._defaultShape().length < e ||
1273
+ (this._removeMarker(i),
1274
+ this._updatePrevNext(i._prev, i._next),
1275
+ i._middleLeft && this._markerGroup.removeLayer(i._middleLeft),
1276
+ i._middleRight && this._markerGroup.removeLayer(i._middleRight),
1277
+ i._prev && i._next
1278
+ ? this._createMiddleMarker(i._prev, i._next)
1279
+ : i._prev
1280
+ ? i._next || (i._prev._middleRight = null)
1281
+ : (i._next._middleLeft = null),
1282
+ this._fireEdit())
1283
+ },
1284
+ _onContextMenu: function (t) {
1285
+ var e = t.target
1286
+ this._poly
1287
+ ;(this._poly._map.fire(L.Draw.Event.MARKERCONTEXT, {
1288
+ marker: e,
1289
+ layers: this._markerGroup,
1290
+ poly: this._poly
1291
+ }),
1292
+ L.DomEvent.stopPropagation)
1293
+ },
1294
+ _onTouchMove: function (t) {
1295
+ var e = this._map.mouseEventToLayerPoint(t.originalEvent.touches[0]),
1296
+ i = this._map.layerPointToLatLng(e),
1297
+ o = t.target
1298
+ ;(L.extend(o._origLatLng, i),
1299
+ o._middleLeft &&
1300
+ o._middleLeft.setLatLng(this._getMiddleLatLng(o._prev, o)),
1301
+ o._middleRight &&
1302
+ o._middleRight.setLatLng(this._getMiddleLatLng(o, o._next)),
1303
+ this._poly.redraw(),
1304
+ this.updateMarkers())
1305
+ },
1306
+ _updateIndexes: function (t, e) {
1307
+ this._markerGroup.eachLayer(function (i) {
1308
+ i._index > t && (i._index += e)
1309
+ })
1310
+ },
1311
+ _createMiddleMarker: function (t, e) {
1312
+ var i,
1313
+ o,
1314
+ a,
1315
+ n = this._getMiddleLatLng(t, e),
1316
+ s = this._createMarker(n)
1317
+ ;(s.setOpacity(0.6),
1318
+ (t._middleRight = e._middleLeft = s),
1319
+ (o = function () {
1320
+ s.off('touchmove', o, this)
1321
+ var a = e._index
1322
+ ;((s._index = a),
1323
+ s.off('click', i, this).on('click', this._onMarkerClick, this),
1324
+ (n.lat = s.getLatLng().lat),
1325
+ (n.lng = s.getLatLng().lng),
1326
+ this._spliceLatLngs(a, 0, n),
1327
+ this._markers.splice(a, 0, s),
1328
+ s.setOpacity(1),
1329
+ this._updateIndexes(a, 1),
1330
+ e._index++,
1331
+ this._updatePrevNext(t, s),
1332
+ this._updatePrevNext(s, e),
1333
+ this._poly.fire('editstart'))
1334
+ }),
1335
+ (a = function () {
1336
+ ;(s.off('dragstart', o, this),
1337
+ s.off('dragend', a, this),
1338
+ s.off('touchmove', o, this),
1339
+ this._createMiddleMarker(t, s),
1340
+ this._createMiddleMarker(s, e))
1341
+ }),
1342
+ (i = function () {
1343
+ ;(o.call(this), a.call(this), this._fireEdit())
1344
+ }),
1345
+ s
1346
+ .on('click', i, this)
1347
+ .on('dragstart', o, this)
1348
+ .on('dragend', a, this)
1349
+ .on('touchmove', o, this),
1350
+ this._markerGroup.addLayer(s))
1351
+ },
1352
+ _updatePrevNext: function (t, e) {
1353
+ ;(t && (t._next = e), e && (e._prev = t))
1354
+ },
1355
+ _getMiddleLatLng: function (t, e) {
1356
+ var i = this._poly._map,
1357
+ o = i.project(t.getLatLng()),
1358
+ a = i.project(e.getLatLng())
1359
+ return i.unproject(o._add(a)._divideBy(2))
1360
+ }
1361
+ })),
1362
+ L.Polyline.addInitHook(function () {
1363
+ this.editing ||
1364
+ (L.Edit.Poly &&
1365
+ ((this.editing = new L.Edit.Poly(this)),
1366
+ this.options.editable && this.editing.enable()),
1367
+ this.on('add', function () {
1368
+ this.editing && this.editing.enabled() && this.editing.addHooks()
1369
+ }),
1370
+ this.on('remove', function () {
1371
+ this.editing && this.editing.enabled() && this.editing.removeHooks()
1372
+ }))
1373
+ }),
1374
+ (L.Edit = L.Edit || {}),
1375
+ (L.Edit.SimpleShape = L.Handler.extend({
1376
+ options: {
1377
+ moveIcon: new L.DivIcon({
1378
+ iconSize: new L.Point(8, 8),
1379
+ className: 'leaflet-div-icon leaflet-editing-icon leaflet-edit-move'
1380
+ }),
1381
+ resizeIcon: new L.DivIcon({
1382
+ iconSize: new L.Point(8, 8),
1383
+ className: 'leaflet-div-icon leaflet-editing-icon leaflet-edit-resize'
1384
+ }),
1385
+ touchMoveIcon: new L.DivIcon({
1386
+ iconSize: new L.Point(20, 20),
1387
+ className:
1388
+ 'leaflet-div-icon leaflet-editing-icon leaflet-edit-move leaflet-touch-icon'
1389
+ }),
1390
+ touchResizeIcon: new L.DivIcon({
1391
+ iconSize: new L.Point(20, 20),
1392
+ className:
1393
+ 'leaflet-div-icon leaflet-editing-icon leaflet-edit-resize leaflet-touch-icon'
1394
+ })
1395
+ },
1396
+ initialize: function (t, e) {
1397
+ ;(L.Browser.touch &&
1398
+ ((this.options.moveIcon = this.options.touchMoveIcon),
1399
+ (this.options.resizeIcon = this.options.touchResizeIcon)),
1400
+ (this._shape = t),
1401
+ L.Util.setOptions(this, e))
1402
+ },
1403
+ addHooks: function () {
1404
+ var t = this._shape
1405
+ this._shape._map &&
1406
+ ((this._map = this._shape._map),
1407
+ t.setStyle(t.options.editing),
1408
+ t._map &&
1409
+ ((this._map = t._map),
1410
+ this._markerGroup || this._initMarkers(),
1411
+ this._map.addLayer(this._markerGroup)))
1412
+ },
1413
+ removeHooks: function () {
1414
+ var t = this._shape
1415
+ if ((t.setStyle(t.options.original), t._map)) {
1416
+ this._unbindMarker(this._moveMarker)
1417
+ for (var e = 0, i = this._resizeMarkers.length; e < i; e++)
1418
+ this._unbindMarker(this._resizeMarkers[e])
1419
+ ;((this._resizeMarkers = null),
1420
+ this._map.removeLayer(this._markerGroup),
1421
+ delete this._markerGroup)
1422
+ }
1423
+ this._map = null
1424
+ },
1425
+ updateMarkers: function () {
1426
+ ;(this._markerGroup.clearLayers(), this._initMarkers())
1427
+ },
1428
+ _initMarkers: function () {
1429
+ ;(this._markerGroup || (this._markerGroup = new L.LayerGroup()),
1430
+ this._createMoveMarker(),
1431
+ this._createResizeMarker())
1432
+ },
1433
+ _createMoveMarker: function () {},
1434
+ _createResizeMarker: function () {},
1435
+ _createMarker: function (t, e) {
1436
+ var i = new L.Marker.Touch(t, {
1437
+ draggable: !0,
1438
+ icon: e,
1439
+ zIndexOffset: 10
1440
+ })
1441
+ return (this._bindMarker(i), this._markerGroup.addLayer(i), i)
1442
+ },
1443
+ _bindMarker: function (t) {
1444
+ t.on('dragstart', this._onMarkerDragStart, this)
1445
+ .on('drag', this._onMarkerDrag, this)
1446
+ .on('dragend', this._onMarkerDragEnd, this)
1447
+ .on('touchstart', this._onTouchStart, this)
1448
+ .on('touchmove', this._onTouchMove, this)
1449
+ .on('MSPointerMove', this._onTouchMove, this)
1450
+ .on('touchend', this._onTouchEnd, this)
1451
+ .on('MSPointerUp', this._onTouchEnd, this)
1452
+ },
1453
+ _unbindMarker: function (t) {
1454
+ t.off('dragstart', this._onMarkerDragStart, this)
1455
+ .off('drag', this._onMarkerDrag, this)
1456
+ .off('dragend', this._onMarkerDragEnd, this)
1457
+ .off('touchstart', this._onTouchStart, this)
1458
+ .off('touchmove', this._onTouchMove, this)
1459
+ .off('MSPointerMove', this._onTouchMove, this)
1460
+ .off('touchend', this._onTouchEnd, this)
1461
+ .off('MSPointerUp', this._onTouchEnd, this)
1462
+ },
1463
+ _onMarkerDragStart: function (t) {
1464
+ ;(t.target.setOpacity(0), this._shape.fire('editstart'))
1465
+ },
1466
+ _fireEdit: function () {
1467
+ ;((this._shape.edited = !0), this._shape.fire('edit'))
1468
+ },
1469
+ _onMarkerDrag: function (t) {
1470
+ var e = t.target,
1471
+ i = e.getLatLng()
1472
+ ;(e === this._moveMarker ? this._move(i) : this._resize(i),
1473
+ this._shape.redraw(),
1474
+ this._shape.fire('editdrag'))
1475
+ },
1476
+ _onMarkerDragEnd: function (t) {
1477
+ ;(t.target.setOpacity(1), this._fireEdit())
1478
+ },
1479
+ _onTouchStart: function (t) {
1480
+ if (
1481
+ (L.Edit.SimpleShape.prototype._onMarkerDragStart.call(this, t),
1482
+ 'function' == typeof this._getCorners)
1483
+ ) {
1484
+ var e = this._getCorners(),
1485
+ i = t.target,
1486
+ o = i._cornerIndex
1487
+ ;(i.setOpacity(0),
1488
+ (this._oppositeCorner = e[(o + 2) % 4]),
1489
+ this._toggleCornerMarkers(0, o))
1490
+ }
1491
+ this._shape.fire('editstart')
1492
+ },
1493
+ _onTouchMove: function (t) {
1494
+ var e = this._map.mouseEventToLayerPoint(t.originalEvent.touches[0]),
1495
+ i = this._map.layerPointToLatLng(e)
1496
+ return (
1497
+ t.target === this._moveMarker ? this._move(i) : this._resize(i),
1498
+ this._shape.redraw(),
1499
+ !1
1500
+ )
1501
+ },
1502
+ _onTouchEnd: function (t) {
1503
+ ;(t.target.setOpacity(1), this.updateMarkers(), this._fireEdit())
1504
+ },
1505
+ _move: function () {},
1506
+ _resize: function () {}
1507
+ })),
1508
+ (L.Edit = L.Edit || {}),
1509
+ (L.Edit.Rectangle = L.Edit.SimpleShape.extend({
1510
+ _createMoveMarker: function () {
1511
+ var t = this._shape.getBounds(),
1512
+ e = t.getCenter()
1513
+ this._moveMarker = this._createMarker(e, this.options.moveIcon)
1514
+ },
1515
+ _createResizeMarker: function () {
1516
+ var t = this._getCorners()
1517
+ this._resizeMarkers = []
1518
+ for (var e = 0, i = t.length; e < i; e++)
1519
+ (this._resizeMarkers.push(
1520
+ this._createMarker(t[e], this.options.resizeIcon)
1521
+ ),
1522
+ (this._resizeMarkers[e]._cornerIndex = e))
1523
+ },
1524
+ _onMarkerDragStart: function (t) {
1525
+ L.Edit.SimpleShape.prototype._onMarkerDragStart.call(this, t)
1526
+ var e = this._getCorners(),
1527
+ i = t.target,
1528
+ o = i._cornerIndex
1529
+ ;((this._oppositeCorner = e[(o + 2) % 4]),
1530
+ this._toggleCornerMarkers(0, o))
1531
+ },
1532
+ _onMarkerDragEnd: function (t) {
1533
+ var e,
1534
+ i,
1535
+ o = t.target
1536
+ ;(o === this._moveMarker &&
1537
+ ((e = this._shape.getBounds()), (i = e.getCenter()), o.setLatLng(i)),
1538
+ this._toggleCornerMarkers(1),
1539
+ this._repositionCornerMarkers(),
1540
+ L.Edit.SimpleShape.prototype._onMarkerDragEnd.call(this, t))
1541
+ },
1542
+ _move: function (t) {
1543
+ for (
1544
+ var e,
1545
+ i = this._shape._defaultShape
1546
+ ? this._shape._defaultShape()
1547
+ : this._shape.getLatLngs(),
1548
+ o = this._shape.getBounds(),
1549
+ a = o.getCenter(),
1550
+ n = [],
1551
+ s = 0,
1552
+ r = i.length;
1553
+ s < r;
1554
+ s++
1555
+ )
1556
+ ((e = [i[s].lat - a.lat, i[s].lng - a.lng]),
1557
+ n.push([t.lat + e[0], t.lng + e[1]]))
1558
+ ;(this._shape.setLatLngs(n),
1559
+ this._repositionCornerMarkers(),
1560
+ this._map.fire(L.Draw.Event.EDITMOVE, { layer: this._shape }))
1561
+ },
1562
+ _resize: function (t) {
1563
+ var e
1564
+ ;(this._shape.setBounds(L.latLngBounds(t, this._oppositeCorner)),
1565
+ (e = this._shape.getBounds()),
1566
+ this._moveMarker.setLatLng(e.getCenter()),
1567
+ this._map.fire(L.Draw.Event.EDITRESIZE, { layer: this._shape }))
1568
+ },
1569
+ _getCorners: function () {
1570
+ var t = this._shape.getBounds()
1571
+ return [
1572
+ t.getNorthWest(),
1573
+ t.getNorthEast(),
1574
+ t.getSouthEast(),
1575
+ t.getSouthWest()
1576
+ ]
1577
+ },
1578
+ _toggleCornerMarkers: function (t) {
1579
+ for (var e = 0, i = this._resizeMarkers.length; e < i; e++)
1580
+ this._resizeMarkers[e].setOpacity(t)
1581
+ },
1582
+ _repositionCornerMarkers: function () {
1583
+ for (
1584
+ var t = this._getCorners(), e = 0, i = this._resizeMarkers.length;
1585
+ e < i;
1586
+ e++
1587
+ )
1588
+ this._resizeMarkers[e].setLatLng(t[e])
1589
+ }
1590
+ })),
1591
+ L.Rectangle.addInitHook(function () {
1592
+ L.Edit.Rectangle &&
1593
+ ((this.editing = new L.Edit.Rectangle(this)),
1594
+ this.options.editable && this.editing.enable())
1595
+ }),
1596
+ (L.Edit = L.Edit || {}),
1597
+ (L.Edit.CircleMarker = L.Edit.SimpleShape.extend({
1598
+ _createMoveMarker: function () {
1599
+ var t = this._shape.getLatLng()
1600
+ this._moveMarker = this._createMarker(t, this.options.moveIcon)
1601
+ },
1602
+ _createResizeMarker: function () {
1603
+ this._resizeMarkers = []
1604
+ },
1605
+ _move: function (t) {
1606
+ if (this._resizeMarkers.length) {
1607
+ var e = this._getResizeMarkerPoint(t)
1608
+ this._resizeMarkers[0].setLatLng(e)
1609
+ }
1610
+ ;(this._shape.setLatLng(t),
1611
+ this._map.fire(L.Draw.Event.EDITMOVE, { layer: this._shape }))
1612
+ }
1613
+ })),
1614
+ L.CircleMarker.addInitHook(function () {
1615
+ ;(L.Edit.CircleMarker &&
1616
+ ((this.editing = new L.Edit.CircleMarker(this)),
1617
+ this.options.editable && this.editing.enable()),
1618
+ this.on('add', function () {
1619
+ this.editing && this.editing.enabled() && this.editing.addHooks()
1620
+ }),
1621
+ this.on('remove', function () {
1622
+ this.editing && this.editing.enabled() && this.editing.removeHooks()
1623
+ }))
1624
+ }),
1625
+ (L.Edit = L.Edit || {}),
1626
+ (L.Edit.Circle = L.Edit.CircleMarker.extend({
1627
+ _createResizeMarker: function () {
1628
+ var t = this._shape.getLatLng(),
1629
+ e = this._getResizeMarkerPoint(t)
1630
+ ;((this._resizeMarkers = []),
1631
+ this._resizeMarkers.push(
1632
+ this._createMarker(e, this.options.resizeIcon)
1633
+ ))
1634
+ },
1635
+ _getResizeMarkerPoint: function (t) {
1636
+ var e = this._shape._radius * Math.cos(Math.PI / 4),
1637
+ i = this._map.project(t)
1638
+ return this._map.unproject([i.x + e, i.y - e])
1639
+ },
1640
+ _resize: function (t) {
1641
+ var e = this._moveMarker.getLatLng()
1642
+ ;(L.GeometryUtil.isVersion07x()
1643
+ ? (radius = e.distanceTo(t))
1644
+ : (radius = this._map.distance(e, t)),
1645
+ this._shape.setRadius(radius),
1646
+ this._map.editTooltip &&
1647
+ this._map._editTooltip.updateContent({
1648
+ text:
1649
+ L.drawLocal.edit.handlers.edit.tooltip.subtext +
1650
+ '<br />' +
1651
+ L.drawLocal.edit.handlers.edit.tooltip.text,
1652
+ subtext:
1653
+ L.drawLocal.draw.handlers.circle.radius +
1654
+ ': ' +
1655
+ L.GeometryUtil.readableDistance(
1656
+ radius,
1657
+ !0,
1658
+ this.options.feet,
1659
+ this.options.nautic
1660
+ )
1661
+ }),
1662
+ this._shape.setRadius(radius),
1663
+ this._map.fire(L.Draw.Event.EDITRESIZE, { layer: this._shape }))
1664
+ }
1665
+ })),
1666
+ L.Circle.addInitHook(function () {
1667
+ L.Edit.Circle &&
1668
+ ((this.editing = new L.Edit.Circle(this)),
1669
+ this.options.editable && this.editing.enable())
1670
+ }),
1671
+ L.Map.mergeOptions({ touchExtend: !0 }),
1672
+ (L.Map.TouchExtend = L.Handler.extend({
1673
+ initialize: function (t) {
1674
+ ;((this._map = t),
1675
+ (this._container = t._container),
1676
+ (this._pane = t._panes.overlayPane))
1677
+ },
1678
+ addHooks: function () {
1679
+ ;(L.DomEvent.on(
1680
+ this._container,
1681
+ 'touchstart',
1682
+ this._onTouchStart,
1683
+ this
1684
+ ),
1685
+ L.DomEvent.on(this._container, 'touchend', this._onTouchEnd, this),
1686
+ L.DomEvent.on(this._container, 'touchmove', this._onTouchMove, this),
1687
+ this._detectIE()
1688
+ ? (L.DomEvent.on(
1689
+ this._container,
1690
+ 'MSPointerDown',
1691
+ this._onTouchStart,
1692
+ this
1693
+ ),
1694
+ L.DomEvent.on(
1695
+ this._container,
1696
+ 'MSPointerUp',
1697
+ this._onTouchEnd,
1698
+ this
1699
+ ),
1700
+ L.DomEvent.on(
1701
+ this._container,
1702
+ 'MSPointerMove',
1703
+ this._onTouchMove,
1704
+ this
1705
+ ),
1706
+ L.DomEvent.on(
1707
+ this._container,
1708
+ 'MSPointerCancel',
1709
+ this._onTouchCancel,
1710
+ this
1711
+ ))
1712
+ : (L.DomEvent.on(
1713
+ this._container,
1714
+ 'touchcancel',
1715
+ this._onTouchCancel,
1716
+ this
1717
+ ),
1718
+ L.DomEvent.on(
1719
+ this._container,
1720
+ 'touchleave',
1721
+ this._onTouchLeave,
1722
+ this
1723
+ )))
1724
+ },
1725
+ removeHooks: function () {
1726
+ ;(L.DomEvent.off(
1727
+ this._container,
1728
+ 'touchstart',
1729
+ this._onTouchStart,
1730
+ this
1731
+ ),
1732
+ L.DomEvent.off(this._container, 'touchend', this._onTouchEnd, this),
1733
+ L.DomEvent.off(this._container, 'touchmove', this._onTouchMove, this),
1734
+ this._detectIE()
1735
+ ? (L.DomEvent.off(
1736
+ this._container,
1737
+ 'MSPointerDown',
1738
+ this._onTouchStart,
1739
+ this
1740
+ ),
1741
+ L.DomEvent.off(
1742
+ this._container,
1743
+ 'MSPointerUp',
1744
+ this._onTouchEnd,
1745
+ this
1746
+ ),
1747
+ L.DomEvent.off(
1748
+ this._container,
1749
+ 'MSPointerMove',
1750
+ this._onTouchMove,
1751
+ this
1752
+ ),
1753
+ L.DomEvent.off(
1754
+ this._container,
1755
+ 'MSPointerCancel',
1756
+ this._onTouchCancel,
1757
+ this
1758
+ ))
1759
+ : (L.DomEvent.off(
1760
+ this._container,
1761
+ 'touchcancel',
1762
+ this._onTouchCancel,
1763
+ this
1764
+ ),
1765
+ L.DomEvent.off(
1766
+ this._container,
1767
+ 'touchleave',
1768
+ this._onTouchLeave,
1769
+ this
1770
+ )))
1771
+ },
1772
+ _touchEvent: function (t, e) {
1773
+ var i = {}
1774
+ if (void 0 !== t.touches) {
1775
+ if (!t.touches.length) return
1776
+ i = t.touches[0]
1777
+ } else {
1778
+ if ('touch' !== t.pointerType) return
1779
+ if (((i = t), !this._filterClick(t))) return
1780
+ }
1781
+ var o = this._map.mouseEventToContainerPoint(i),
1782
+ a = this._map.mouseEventToLayerPoint(i),
1783
+ n = this._map.layerPointToLatLng(a)
1784
+ this._map.fire(e, {
1785
+ latlng: n,
1786
+ layerPoint: a,
1787
+ containerPoint: o,
1788
+ pageX: i.pageX,
1789
+ pageY: i.pageY,
1790
+ originalEvent: t
1791
+ })
1792
+ },
1793
+ _filterClick: function (t) {
1794
+ var e = t.timeStamp || t.originalEvent.timeStamp,
1795
+ i = L.DomEvent._lastClick && e - L.DomEvent._lastClick
1796
+ return (i && i > 100 && i < 500) ||
1797
+ (t.target._simulatedClick && !t._simulated)
1798
+ ? (L.DomEvent.stop(t), !1)
1799
+ : ((L.DomEvent._lastClick = e), !0)
1800
+ },
1801
+ _onTouchStart: function (t) {
1802
+ if (this._map._loaded) {
1803
+ this._touchEvent(t, 'touchstart')
1804
+ }
1805
+ },
1806
+ _onTouchEnd: function (t) {
1807
+ if (this._map._loaded) {
1808
+ this._touchEvent(t, 'touchend')
1809
+ }
1810
+ },
1811
+ _onTouchCancel: function (t) {
1812
+ if (this._map._loaded) {
1813
+ var e = 'touchcancel'
1814
+ ;(this._detectIE() && (e = 'pointercancel'), this._touchEvent(t, e))
1815
+ }
1816
+ },
1817
+ _onTouchLeave: function (t) {
1818
+ if (this._map._loaded) {
1819
+ this._touchEvent(t, 'touchleave')
1820
+ }
1821
+ },
1822
+ _onTouchMove: function (t) {
1823
+ if (this._map._loaded) {
1824
+ this._touchEvent(t, 'touchmove')
1825
+ }
1826
+ },
1827
+ _detectIE: function () {
1828
+ var e = t.navigator.userAgent,
1829
+ i = e.indexOf('MSIE ')
1830
+ if (i > 0) return parseInt(e.substring(i + 5, e.indexOf('.', i)), 10)
1831
+ if (e.indexOf('Trident/') > 0) {
1832
+ var o = e.indexOf('rv:')
1833
+ return parseInt(e.substring(o + 3, e.indexOf('.', o)), 10)
1834
+ }
1835
+ var a = e.indexOf('Edge/')
1836
+ return a > 0 && parseInt(e.substring(a + 5, e.indexOf('.', a)), 10)
1837
+ }
1838
+ })),
1839
+ L.Map.addInitHook('addHandler', 'touchExtend', L.Map.TouchExtend),
1840
+ (L.Marker.Touch = L.Marker.extend({
1841
+ _initInteraction: function () {
1842
+ return this.addInteractiveTarget
1843
+ ? L.Marker.prototype._initInteraction.apply(this)
1844
+ : this._initInteractionLegacy()
1845
+ },
1846
+ _initInteractionLegacy: function () {
1847
+ if (this.options.clickable) {
1848
+ var t = this._icon,
1849
+ e = [
1850
+ 'dblclick',
1851
+ 'mousedown',
1852
+ 'mouseover',
1853
+ 'mouseout',
1854
+ 'contextmenu',
1855
+ 'touchstart',
1856
+ 'touchend',
1857
+ 'touchmove'
1858
+ ]
1859
+ ;(this._detectIE
1860
+ ? e.concat([
1861
+ 'MSPointerDown',
1862
+ 'MSPointerUp',
1863
+ 'MSPointerMove',
1864
+ 'MSPointerCancel'
1865
+ ])
1866
+ : e.concat(['touchcancel']),
1867
+ L.DomUtil.addClass(t, 'leaflet-clickable'),
1868
+ L.DomEvent.on(t, 'click', this._onMouseClick, this),
1869
+ L.DomEvent.on(t, 'keypress', this._onKeyPress, this))
1870
+ for (var i = 0; i < e.length; i++)
1871
+ L.DomEvent.on(t, e[i], this._fireMouseEvent, this)
1872
+ L.Handler.MarkerDrag &&
1873
+ ((this.dragging = new L.Handler.MarkerDrag(this)),
1874
+ this.options.draggable && this.dragging.enable())
1875
+ }
1876
+ },
1877
+ _detectIE: function () {
1878
+ var e = t.navigator.userAgent,
1879
+ i = e.indexOf('MSIE ')
1880
+ if (i > 0) return parseInt(e.substring(i + 5, e.indexOf('.', i)), 10)
1881
+ if (e.indexOf('Trident/') > 0) {
1882
+ var o = e.indexOf('rv:')
1883
+ return parseInt(e.substring(o + 3, e.indexOf('.', o)), 10)
1884
+ }
1885
+ var a = e.indexOf('Edge/')
1886
+ return a > 0 && parseInt(e.substring(a + 5, e.indexOf('.', a)), 10)
1887
+ }
1888
+ })),
1889
+ (L.LatLngUtil = {
1890
+ cloneLatLngs: function (t) {
1891
+ for (var e = [], i = 0, o = t.length; i < o; i++)
1892
+ Array.isArray(t[i])
1893
+ ? e.push(L.LatLngUtil.cloneLatLngs(t[i]))
1894
+ : e.push(this.cloneLatLng(t[i]))
1895
+ return e
1896
+ },
1897
+ cloneLatLng: function (t) {
1898
+ return L.latLng(t.lat, t.lng)
1899
+ }
1900
+ }),
1901
+ (function () {
1902
+ var t = { km: 2, ha: 2, m: 0, mi: 2, ac: 2, yd: 0, ft: 0, nm: 2 }
1903
+ L.GeometryUtil = L.extend(L.GeometryUtil || {}, {
1904
+ geodesicArea: function (t) {
1905
+ var e,
1906
+ i,
1907
+ o = t.length,
1908
+ a = 0,
1909
+ n = Math.PI / 180
1910
+ if (o > 2) {
1911
+ for (var s = 0; s < o; s++)
1912
+ ((e = t[s]),
1913
+ (i = t[(s + 1) % o]),
1914
+ (a +=
1915
+ (i.lng - e.lng) *
1916
+ n *
1917
+ (2 + Math.sin(e.lat * n) + Math.sin(i.lat * n))))
1918
+ a = (6378137 * a * 6378137) / 2
1919
+ }
1920
+ return Math.abs(a)
1921
+ },
1922
+ formattedNumber: function (t, e) {
1923
+ var i = parseFloat(t).toFixed(e),
1924
+ o = L.drawLocal.format && L.drawLocal.format.numeric,
1925
+ a = o && o.delimiters,
1926
+ n = a && a.thousands,
1927
+ s = a && a.decimal
1928
+ if (n || s) {
1929
+ var r = i.split('.')
1930
+ ;((i = n
1931
+ ? r[0].replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1' + n)
1932
+ : r[0]),
1933
+ (s = s || '.'),
1934
+ r.length > 1 && (i = i + s + r[1]))
1935
+ }
1936
+ return i
1937
+ },
1938
+ readableArea: function (e, i, o) {
1939
+ var a,
1940
+ n,
1941
+ o = L.Util.extend({}, t, o)
1942
+ return (
1943
+ i
1944
+ ? ((n = ['ha', 'm']),
1945
+ (type = typeof i),
1946
+ 'string' === type ? (n = [i]) : 'boolean' !== type && (n = i),
1947
+ (a =
1948
+ e >= 1e6 && -1 !== n.indexOf('km')
1949
+ ? L.GeometryUtil.formattedNumber(1e-6 * e, o.km) + ' km²'
1950
+ : e >= 1e4 && -1 !== n.indexOf('ha')
1951
+ ? L.GeometryUtil.formattedNumber(1e-4 * e, o.ha) + ' ha'
1952
+ : L.GeometryUtil.formattedNumber(e, o.m) + ' m²'))
1953
+ : ((e /= 0.836127),
1954
+ (a =
1955
+ e >= 3097600
1956
+ ? L.GeometryUtil.formattedNumber(e / 3097600, o.mi) + ' mi²'
1957
+ : e >= 4840
1958
+ ? L.GeometryUtil.formattedNumber(e / 4840, o.ac) +
1959
+ ' acres'
1960
+ : L.GeometryUtil.formattedNumber(e, o.yd) + ' yd²')),
1961
+ a
1962
+ )
1963
+ },
1964
+ readableDistance: function (e, i, o, a, n) {
1965
+ var s,
1966
+ n = L.Util.extend({}, t, n)
1967
+ switch (
1968
+ i
1969
+ ? 'string' == typeof i
1970
+ ? i
1971
+ : 'metric'
1972
+ : o
1973
+ ? 'feet'
1974
+ : a
1975
+ ? 'nauticalMile'
1976
+ : 'yards'
1977
+ ) {
1978
+ case 'metric':
1979
+ s =
1980
+ e > 1e3
1981
+ ? L.GeometryUtil.formattedNumber(e / 1e3, n.km) + ' km'
1982
+ : L.GeometryUtil.formattedNumber(e, n.m) + ' m'
1983
+ break
1984
+ case 'feet':
1985
+ ;((e *= 3.28083),
1986
+ (s = L.GeometryUtil.formattedNumber(e, n.ft) + ' ft'))
1987
+ break
1988
+ case 'nauticalMile':
1989
+ ;((e *= 0.53996),
1990
+ (s = L.GeometryUtil.formattedNumber(e / 1e3, n.nm) + ' nm'))
1991
+ break
1992
+ case 'yards':
1993
+ default:
1994
+ ;((e *= 1.09361),
1995
+ (s =
1996
+ e > 1760
1997
+ ? L.GeometryUtil.formattedNumber(e / 1760, n.mi) + ' miles'
1998
+ : L.GeometryUtil.formattedNumber(e, n.yd) + ' yd'))
1999
+ }
2000
+ return s
2001
+ },
2002
+ isVersion07x: function () {
2003
+ var t = L.version.split('.')
2004
+ return 0 === parseInt(t[0], 10) && 7 === parseInt(t[1], 10)
2005
+ }
2006
+ })
2007
+ })(),
2008
+ L.Util.extend(L.LineUtil, {
2009
+ segmentsIntersect: function (t, e, i, o) {
2010
+ return (
2011
+ this._checkCounterclockwise(t, i, o) !==
2012
+ this._checkCounterclockwise(e, i, o) &&
2013
+ this._checkCounterclockwise(t, e, i) !==
2014
+ this._checkCounterclockwise(t, e, o)
2015
+ )
2016
+ },
2017
+ _checkCounterclockwise: function (t, e, i) {
2018
+ return (i.y - t.y) * (e.x - t.x) > (e.y - t.y) * (i.x - t.x)
2019
+ }
2020
+ }),
2021
+ L.Polyline.include({
2022
+ intersects: function () {
2023
+ var t,
2024
+ e,
2025
+ i,
2026
+ o = this._getProjectedPoints(),
2027
+ a = o ? o.length : 0
2028
+ if (this._tooFewPointsForIntersection()) return !1
2029
+ for (t = a - 1; t >= 3; t--)
2030
+ if (
2031
+ ((e = o[t - 1]),
2032
+ (i = o[t]),
2033
+ this._lineSegmentsIntersectsRange(e, i, t - 2))
2034
+ )
2035
+ return !0
2036
+ return !1
2037
+ },
2038
+ newLatLngIntersects: function (t, e) {
2039
+ return (
2040
+ !!this._map &&
2041
+ this.newPointIntersects(this._map.latLngToLayerPoint(t), e)
2042
+ )
2043
+ },
2044
+ newPointIntersects: function (t, e) {
2045
+ var i = this._getProjectedPoints(),
2046
+ o = i ? i.length : 0,
2047
+ a = i ? i[o - 1] : null,
2048
+ n = o - 2
2049
+ return (
2050
+ !this._tooFewPointsForIntersection(1) &&
2051
+ this._lineSegmentsIntersectsRange(a, t, n, e ? 1 : 0)
2052
+ )
2053
+ },
2054
+ _tooFewPointsForIntersection: function (t) {
2055
+ var e = this._getProjectedPoints(),
2056
+ i = e ? e.length : 0
2057
+ return ((i += t || 0), !e || i <= 3)
2058
+ },
2059
+ _lineSegmentsIntersectsRange: function (t, e, i, o) {
2060
+ var a,
2061
+ n,
2062
+ s = this._getProjectedPoints()
2063
+ o = o || 0
2064
+ for (var r = i; r > o; r--)
2065
+ if (
2066
+ ((a = s[r - 1]),
2067
+ (n = s[r]),
2068
+ L.LineUtil.segmentsIntersect(t, e, a, n))
2069
+ )
2070
+ return !0
2071
+ return !1
2072
+ },
2073
+ _getProjectedPoints: function () {
2074
+ if (!this._defaultShape) return this._originalPoints
2075
+ for (var t = [], e = this._defaultShape(), i = 0; i < e.length; i++)
2076
+ t.push(this._map.latLngToLayerPoint(e[i]))
2077
+ return t
2078
+ }
2079
+ }),
2080
+ L.Polygon.include({
2081
+ intersects: function () {
2082
+ var t,
2083
+ e,
2084
+ i,
2085
+ o,
2086
+ a = this._getProjectedPoints()
2087
+ return (
2088
+ !this._tooFewPointsForIntersection() &&
2089
+ (!!L.Polyline.prototype.intersects.call(this) ||
2090
+ ((t = a.length),
2091
+ (e = a[0]),
2092
+ (i = a[t - 1]),
2093
+ (o = t - 2),
2094
+ this._lineSegmentsIntersectsRange(i, e, o, 1)))
2095
+ )
2096
+ }
2097
+ }),
2098
+ (L.Control.Draw = L.Control.extend({
2099
+ options: { position: 'topleft', draw: {}, edit: !1 },
2100
+ initialize: function (t) {
2101
+ if (L.version < '0.7')
2102
+ throw new Error(
2103
+ 'Leaflet.draw 0.2.3+ requires Leaflet 0.7.0+. Download latest from https://github.com/Leaflet/Leaflet/'
2104
+ )
2105
+ L.Control.prototype.initialize.call(this, t)
2106
+ var e
2107
+ ;((this._toolbars = {}),
2108
+ L.DrawToolbar &&
2109
+ this.options.draw &&
2110
+ ((e = new L.DrawToolbar(this.options.draw)),
2111
+ (this._toolbars[L.DrawToolbar.TYPE] = e),
2112
+ this._toolbars[L.DrawToolbar.TYPE].on(
2113
+ 'enable',
2114
+ this._toolbarEnabled,
2115
+ this
2116
+ )),
2117
+ L.EditToolbar &&
2118
+ this.options.edit &&
2119
+ ((e = new L.EditToolbar(this.options.edit)),
2120
+ (this._toolbars[L.EditToolbar.TYPE] = e),
2121
+ this._toolbars[L.EditToolbar.TYPE].on(
2122
+ 'enable',
2123
+ this._toolbarEnabled,
2124
+ this
2125
+ )),
2126
+ (L.toolbar = this))
2127
+ },
2128
+ onAdd: function (t) {
2129
+ var e,
2130
+ i = L.DomUtil.create('div', 'leaflet-draw'),
2131
+ o = !1
2132
+ for (var a in this._toolbars)
2133
+ this._toolbars.hasOwnProperty(a) &&
2134
+ (e = this._toolbars[a].addToolbar(t)) &&
2135
+ (o ||
2136
+ (L.DomUtil.hasClass(e, 'leaflet-draw-toolbar-top') ||
2137
+ L.DomUtil.addClass(e.childNodes[0], 'leaflet-draw-toolbar-top'),
2138
+ (o = !0)),
2139
+ i.appendChild(e))
2140
+ return i
2141
+ },
2142
+ onRemove: function () {
2143
+ for (var t in this._toolbars)
2144
+ this._toolbars.hasOwnProperty(t) && this._toolbars[t].removeToolbar()
2145
+ },
2146
+ setDrawingOptions: function (t) {
2147
+ for (var e in this._toolbars)
2148
+ this._toolbars[e] instanceof L.DrawToolbar &&
2149
+ this._toolbars[e].setOptions(t)
2150
+ },
2151
+ _toolbarEnabled: function (t) {
2152
+ var e = t.target
2153
+ for (var i in this._toolbars)
2154
+ this._toolbars[i] !== e && this._toolbars[i].disable()
2155
+ }
2156
+ })),
2157
+ L.Map.mergeOptions({ drawControlTooltips: !0, drawControl: !1 }),
2158
+ L.Map.addInitHook(function () {
2159
+ this.options.drawControl &&
2160
+ ((this.drawControl = new L.Control.Draw()),
2161
+ this.addControl(this.drawControl))
2162
+ }),
2163
+ (L.Toolbar = L.Class.extend({
2164
+ initialize: function (t) {
2165
+ ;(L.setOptions(this, t),
2166
+ (this._modes = {}),
2167
+ (this._actionButtons = []),
2168
+ (this._activeMode = null))
2169
+ var e = L.version.split('.')
2170
+ 1 === parseInt(e[0], 10) && parseInt(e[1], 10) >= 2
2171
+ ? L.Toolbar.include(L.Evented.prototype)
2172
+ : L.Toolbar.include(L.Mixin.Events)
2173
+ },
2174
+ enabled: function () {
2175
+ return null !== this._activeMode
2176
+ },
2177
+ disable: function () {
2178
+ this.enabled() && this._activeMode.handler.disable()
2179
+ },
2180
+ addToolbar: function (t) {
2181
+ var e,
2182
+ i = L.DomUtil.create('div', 'leaflet-draw-section'),
2183
+ o = 0,
2184
+ a = this._toolbarClass || '',
2185
+ n = this.getModeHandlers(t)
2186
+ for (
2187
+ this._toolbarContainer = L.DomUtil.create(
2188
+ 'div',
2189
+ 'leaflet-draw-toolbar leaflet-bar'
2190
+ ),
2191
+ this._map = t,
2192
+ e = 0;
2193
+ e < n.length;
2194
+ e++
2195
+ )
2196
+ n[e].enabled &&
2197
+ this._initModeHandler(
2198
+ n[e].handler,
2199
+ this._toolbarContainer,
2200
+ o++,
2201
+ a,
2202
+ n[e].title
2203
+ )
2204
+ if (o)
2205
+ return (
2206
+ (this._lastButtonIndex = --o),
2207
+ (this._actionsContainer = L.DomUtil.create(
2208
+ 'ul',
2209
+ 'leaflet-draw-actions'
2210
+ )),
2211
+ i.appendChild(this._toolbarContainer),
2212
+ i.appendChild(this._actionsContainer),
2213
+ i
2214
+ )
2215
+ },
2216
+ removeToolbar: function () {
2217
+ for (var t in this._modes)
2218
+ this._modes.hasOwnProperty(t) &&
2219
+ (this._disposeButton(
2220
+ this._modes[t].button,
2221
+ this._modes[t].handler.enable,
2222
+ this._modes[t].handler
2223
+ ),
2224
+ this._modes[t].handler.disable(),
2225
+ this._modes[t].handler
2226
+ .off('enabled', this._handlerActivated, this)
2227
+ .off('disabled', this._handlerDeactivated, this))
2228
+ this._modes = {}
2229
+ for (var e = 0, i = this._actionButtons.length; e < i; e++)
2230
+ this._disposeButton(
2231
+ this._actionButtons[e].button,
2232
+ this._actionButtons[e].callback,
2233
+ this
2234
+ )
2235
+ ;((this._actionButtons = []), (this._actionsContainer = null))
2236
+ },
2237
+ _initModeHandler: function (t, e, i, o, a) {
2238
+ var n = t.type
2239
+ ;((this._modes[n] = {}),
2240
+ (this._modes[n].handler = t),
2241
+ (this._modes[n].button = this._createButton({
2242
+ type: n,
2243
+ title: a,
2244
+ className: o + '-' + n,
2245
+ container: e,
2246
+ callback: this._modes[n].handler.enable,
2247
+ context: this._modes[n].handler
2248
+ })),
2249
+ (this._modes[n].buttonIndex = i),
2250
+ this._modes[n].handler
2251
+ .on('enabled', this._handlerActivated, this)
2252
+ .on('disabled', this._handlerDeactivated, this))
2253
+ },
2254
+ _detectIOS: function () {
2255
+ return /iPad|iPhone|iPod/.test(navigator.userAgent) && !t.MSStream
2256
+ },
2257
+ _createButton: function (t) {
2258
+ var e = L.DomUtil.create('a', t.className || '', t.container),
2259
+ i = L.DomUtil.create('span', 'sr-only', t.container)
2260
+ ;((e.href = '#'),
2261
+ e.appendChild(i),
2262
+ t.title && ((e.title = t.title), (i.innerHTML = t.title)),
2263
+ t.text && ((e.innerHTML = t.text), (i.innerHTML = t.text)))
2264
+ var o = this._detectIOS() ? 'touchstart' : 'click'
2265
+ return (
2266
+ L.DomEvent.on(e, 'click', L.DomEvent.stopPropagation)
2267
+ .on(e, 'mousedown', L.DomEvent.stopPropagation)
2268
+ .on(e, 'dblclick', L.DomEvent.stopPropagation)
2269
+ .on(e, 'touchstart', L.DomEvent.stopPropagation)
2270
+ .on(e, 'click', L.DomEvent.preventDefault)
2271
+ .on(e, o, t.callback, t.context),
2272
+ e
2273
+ )
2274
+ },
2275
+ _disposeButton: function (t, e) {
2276
+ var i = this._detectIOS() ? 'touchstart' : 'click'
2277
+ L.DomEvent.off(t, 'click', L.DomEvent.stopPropagation)
2278
+ .off(t, 'mousedown', L.DomEvent.stopPropagation)
2279
+ .off(t, 'dblclick', L.DomEvent.stopPropagation)
2280
+ .off(t, 'touchstart', L.DomEvent.stopPropagation)
2281
+ .off(t, 'click', L.DomEvent.preventDefault)
2282
+ .off(t, i, e)
2283
+ },
2284
+ _handlerActivated: function (t) {
2285
+ ;(this.disable(),
2286
+ (this._activeMode = this._modes[t.handler]),
2287
+ L.DomUtil.addClass(
2288
+ this._activeMode.button,
2289
+ 'leaflet-draw-toolbar-button-enabled'
2290
+ ),
2291
+ this._showActionsToolbar(),
2292
+ this.fire('enable'))
2293
+ },
2294
+ _handlerDeactivated: function () {
2295
+ ;(this._hideActionsToolbar(),
2296
+ L.DomUtil.removeClass(
2297
+ this._activeMode.button,
2298
+ 'leaflet-draw-toolbar-button-enabled'
2299
+ ),
2300
+ (this._activeMode = null),
2301
+ this.fire('disable'))
2302
+ },
2303
+ _createActions: function (t) {
2304
+ var e,
2305
+ i,
2306
+ o,
2307
+ a,
2308
+ n = this._actionsContainer,
2309
+ s = this.getActions(t),
2310
+ r = s.length
2311
+ for (i = 0, o = this._actionButtons.length; i < o; i++)
2312
+ this._disposeButton(
2313
+ this._actionButtons[i].button,
2314
+ this._actionButtons[i].callback
2315
+ )
2316
+ for (this._actionButtons = []; n.firstChild; )
2317
+ n.removeChild(n.firstChild)
2318
+ for (var l = 0; l < r; l++)
2319
+ ('enabled' in s[l] && !s[l].enabled) ||
2320
+ ((e = L.DomUtil.create('li', '', n)),
2321
+ (a = this._createButton({
2322
+ title: s[l].title,
2323
+ text: s[l].text,
2324
+ container: e,
2325
+ callback: s[l].callback,
2326
+ context: s[l].context
2327
+ })),
2328
+ this._actionButtons.push({ button: a, callback: s[l].callback }))
2329
+ },
2330
+ _showActionsToolbar: function () {
2331
+ var t = this._activeMode.buttonIndex,
2332
+ e = this._lastButtonIndex,
2333
+ i = this._activeMode.button.offsetTop - 1
2334
+ ;(this._createActions(this._activeMode.handler),
2335
+ (this._actionsContainer.style.top = i + 'px'),
2336
+ 0 === t &&
2337
+ (L.DomUtil.addClass(
2338
+ this._toolbarContainer,
2339
+ 'leaflet-draw-toolbar-notop'
2340
+ ),
2341
+ L.DomUtil.addClass(
2342
+ this._actionsContainer,
2343
+ 'leaflet-draw-actions-top'
2344
+ )),
2345
+ t === e &&
2346
+ (L.DomUtil.addClass(
2347
+ this._toolbarContainer,
2348
+ 'leaflet-draw-toolbar-nobottom'
2349
+ ),
2350
+ L.DomUtil.addClass(
2351
+ this._actionsContainer,
2352
+ 'leaflet-draw-actions-bottom'
2353
+ )),
2354
+ (this._actionsContainer.style.display = 'block'),
2355
+ this._map.fire(L.Draw.Event.TOOLBAROPENED))
2356
+ },
2357
+ _hideActionsToolbar: function () {
2358
+ ;((this._actionsContainer.style.display = 'none'),
2359
+ L.DomUtil.removeClass(
2360
+ this._toolbarContainer,
2361
+ 'leaflet-draw-toolbar-notop'
2362
+ ),
2363
+ L.DomUtil.removeClass(
2364
+ this._toolbarContainer,
2365
+ 'leaflet-draw-toolbar-nobottom'
2366
+ ),
2367
+ L.DomUtil.removeClass(
2368
+ this._actionsContainer,
2369
+ 'leaflet-draw-actions-top'
2370
+ ),
2371
+ L.DomUtil.removeClass(
2372
+ this._actionsContainer,
2373
+ 'leaflet-draw-actions-bottom'
2374
+ ),
2375
+ this._map.fire(L.Draw.Event.TOOLBARCLOSED))
2376
+ }
2377
+ })),
2378
+ (L.Draw = L.Draw || {}),
2379
+ (L.Draw.Tooltip = L.Class.extend({
2380
+ initialize: function (t) {
2381
+ ;((this._map = t),
2382
+ (this._popupPane = t._panes.popupPane),
2383
+ (this._visible = !1),
2384
+ (this._container = t.options.drawControlTooltips
2385
+ ? L.DomUtil.create('div', 'leaflet-draw-tooltip', this._popupPane)
2386
+ : null),
2387
+ (this._singleLineLabel = !1),
2388
+ this._map.on('mouseout', this._onMouseOut, this))
2389
+ },
2390
+ dispose: function () {
2391
+ ;(this._map.off('mouseout', this._onMouseOut, this),
2392
+ this._container &&
2393
+ (this._popupPane.removeChild(this._container),
2394
+ (this._container = null)))
2395
+ },
2396
+ updateContent: function (t) {
2397
+ return this._container
2398
+ ? ((t.subtext = t.subtext || ''),
2399
+ 0 !== t.subtext.length || this._singleLineLabel
2400
+ ? t.subtext.length > 0 &&
2401
+ this._singleLineLabel &&
2402
+ (L.DomUtil.removeClass(
2403
+ this._container,
2404
+ 'leaflet-draw-tooltip-single'
2405
+ ),
2406
+ (this._singleLineLabel = !1))
2407
+ : (L.DomUtil.addClass(
2408
+ this._container,
2409
+ 'leaflet-draw-tooltip-single'
2410
+ ),
2411
+ (this._singleLineLabel = !0)),
2412
+ (this._container.innerHTML =
2413
+ (t.subtext.length > 0
2414
+ ? '<span class="leaflet-draw-tooltip-subtext">' +
2415
+ t.subtext +
2416
+ '</span><br />'
2417
+ : '') +
2418
+ '<span>' +
2419
+ t.text +
2420
+ '</span>'),
2421
+ t.text || t.subtext
2422
+ ? ((this._visible = !0),
2423
+ (this._container.style.visibility = 'inherit'))
2424
+ : ((this._visible = !1),
2425
+ (this._container.style.visibility = 'hidden')),
2426
+ this)
2427
+ : this
2428
+ },
2429
+ updatePosition: function (t) {
2430
+ var e = this._map.latLngToLayerPoint(t),
2431
+ i = this._container
2432
+ return (
2433
+ this._container &&
2434
+ (this._visible && (i.style.visibility = 'inherit'),
2435
+ L.DomUtil.setPosition(i, e)),
2436
+ this
2437
+ )
2438
+ },
2439
+ showAsError: function () {
2440
+ return (
2441
+ this._container &&
2442
+ L.DomUtil.addClass(this._container, 'leaflet-error-draw-tooltip'),
2443
+ this
2444
+ )
2445
+ },
2446
+ removeError: function () {
2447
+ return (
2448
+ this._container &&
2449
+ L.DomUtil.removeClass(
2450
+ this._container,
2451
+ 'leaflet-error-draw-tooltip'
2452
+ ),
2453
+ this
2454
+ )
2455
+ },
2456
+ _onMouseOut: function () {
2457
+ this._container && (this._container.style.visibility = 'hidden')
2458
+ }
2459
+ })),
2460
+ (L.DrawToolbar = L.Toolbar.extend({
2461
+ statics: { TYPE: 'draw' },
2462
+ options: {
2463
+ polyline: {},
2464
+ polygon: {},
2465
+ rectangle: {},
2466
+ circle: {},
2467
+ marker: {},
2468
+ circlemarker: {}
2469
+ },
2470
+ initialize: function (t) {
2471
+ for (var e in this.options)
2472
+ this.options.hasOwnProperty(e) &&
2473
+ t[e] &&
2474
+ (t[e] = L.extend({}, this.options[e], t[e]))
2475
+ ;((this._toolbarClass = 'leaflet-draw-draw'),
2476
+ L.Toolbar.prototype.initialize.call(this, t))
2477
+ },
2478
+ getModeHandlers: function (t) {
2479
+ return [
2480
+ {
2481
+ enabled: this.options.polyline,
2482
+ handler: new L.Draw.Polyline(t, this.options.polyline),
2483
+ title: L.drawLocal.draw.toolbar.buttons.polyline
2484
+ },
2485
+ {
2486
+ enabled: this.options.polygon,
2487
+ handler: new L.Draw.Polygon(t, this.options.polygon),
2488
+ title: L.drawLocal.draw.toolbar.buttons.polygon
2489
+ },
2490
+ {
2491
+ enabled: this.options.rectangle,
2492
+ handler: new L.Draw.Rectangle(t, this.options.rectangle),
2493
+ title: L.drawLocal.draw.toolbar.buttons.rectangle
2494
+ },
2495
+ {
2496
+ enabled: this.options.circle,
2497
+ handler: new L.Draw.Circle(t, this.options.circle),
2498
+ title: L.drawLocal.draw.toolbar.buttons.circle
2499
+ },
2500
+ {
2501
+ enabled: this.options.marker,
2502
+ handler: new L.Draw.Marker(t, this.options.marker),
2503
+ title: L.drawLocal.draw.toolbar.buttons.marker
2504
+ },
2505
+ {
2506
+ enabled: this.options.circlemarker,
2507
+ handler: new L.Draw.CircleMarker(t, this.options.circlemarker),
2508
+ title: L.drawLocal.draw.toolbar.buttons.circlemarker
2509
+ }
2510
+ ]
2511
+ },
2512
+ getActions: function (t) {
2513
+ return [
2514
+ {
2515
+ enabled: t.completeShape,
2516
+ title: L.drawLocal.draw.toolbar.finish.title,
2517
+ text: L.drawLocal.draw.toolbar.finish.text,
2518
+ callback: t.completeShape,
2519
+ context: t
2520
+ },
2521
+ {
2522
+ enabled: t.deleteLastVertex,
2523
+ title: L.drawLocal.draw.toolbar.undo.title,
2524
+ text: L.drawLocal.draw.toolbar.undo.text,
2525
+ callback: t.deleteLastVertex,
2526
+ context: t
2527
+ },
2528
+ {
2529
+ title: L.drawLocal.draw.toolbar.actions.title,
2530
+ text: L.drawLocal.draw.toolbar.actions.text,
2531
+ callback: this.disable,
2532
+ context: this
2533
+ }
2534
+ ]
2535
+ },
2536
+ setOptions: function (t) {
2537
+ L.setOptions(this, t)
2538
+ for (var e in this._modes)
2539
+ this._modes.hasOwnProperty(e) &&
2540
+ t.hasOwnProperty(e) &&
2541
+ this._modes[e].handler.setOptions(t[e])
2542
+ }
2543
+ })),
2544
+ (L.EditToolbar = L.Toolbar.extend({
2545
+ statics: { TYPE: 'edit' },
2546
+ options: {
2547
+ edit: {
2548
+ selectedPathOptions: {
2549
+ dashArray: '10, 10',
2550
+ fill: !0,
2551
+ fillColor: '#fe57a1',
2552
+ fillOpacity: 0.1,
2553
+ maintainColor: !1
2554
+ }
2555
+ },
2556
+ remove: {},
2557
+ poly: null,
2558
+ featureGroup: null
2559
+ },
2560
+ initialize: function (t) {
2561
+ ;(t.edit &&
2562
+ (void 0 === t.edit.selectedPathOptions &&
2563
+ (t.edit.selectedPathOptions =
2564
+ this.options.edit.selectedPathOptions),
2565
+ (t.edit.selectedPathOptions = L.extend(
2566
+ {},
2567
+ this.options.edit.selectedPathOptions,
2568
+ t.edit.selectedPathOptions
2569
+ ))),
2570
+ t.remove && (t.remove = L.extend({}, this.options.remove, t.remove)),
2571
+ t.poly && (t.poly = L.extend({}, this.options.poly, t.poly)),
2572
+ (this._toolbarClass = 'leaflet-draw-edit'),
2573
+ L.Toolbar.prototype.initialize.call(this, t),
2574
+ (this._selectedFeatureCount = 0))
2575
+ },
2576
+ getModeHandlers: function (t) {
2577
+ var e = this.options.featureGroup
2578
+ return [
2579
+ {
2580
+ enabled: this.options.edit,
2581
+ handler: new L.EditToolbar.Edit(t, {
2582
+ featureGroup: e,
2583
+ selectedPathOptions: this.options.edit.selectedPathOptions,
2584
+ poly: this.options.poly
2585
+ }),
2586
+ title: L.drawLocal.edit.toolbar.buttons.edit
2587
+ },
2588
+ {
2589
+ enabled: this.options.remove,
2590
+ handler: new L.EditToolbar.Delete(t, { featureGroup: e }),
2591
+ title: L.drawLocal.edit.toolbar.buttons.remove
2592
+ }
2593
+ ]
2594
+ },
2595
+ getActions: function (t) {
2596
+ var e = [
2597
+ {
2598
+ title: L.drawLocal.edit.toolbar.actions.save.title,
2599
+ text: L.drawLocal.edit.toolbar.actions.save.text,
2600
+ callback: this._save,
2601
+ context: this
2602
+ },
2603
+ {
2604
+ title: L.drawLocal.edit.toolbar.actions.cancel.title,
2605
+ text: L.drawLocal.edit.toolbar.actions.cancel.text,
2606
+ callback: this.disable,
2607
+ context: this
2608
+ }
2609
+ ]
2610
+ return (
2611
+ t.removeAllLayers &&
2612
+ e.push({
2613
+ title: L.drawLocal.edit.toolbar.actions.clearAll.title,
2614
+ text: L.drawLocal.edit.toolbar.actions.clearAll.text,
2615
+ callback: this._clearAllLayers,
2616
+ context: this
2617
+ }),
2618
+ e
2619
+ )
2620
+ },
2621
+ addToolbar: function (t) {
2622
+ var e = L.Toolbar.prototype.addToolbar.call(this, t)
2623
+ return (
2624
+ this._checkDisabled(),
2625
+ this.options.featureGroup.on(
2626
+ 'layeradd layerremove',
2627
+ this._checkDisabled,
2628
+ this
2629
+ ),
2630
+ e
2631
+ )
2632
+ },
2633
+ removeToolbar: function () {
2634
+ ;(this.options.featureGroup.off(
2635
+ 'layeradd layerremove',
2636
+ this._checkDisabled,
2637
+ this
2638
+ ),
2639
+ L.Toolbar.prototype.removeToolbar.call(this))
2640
+ },
2641
+ disable: function () {
2642
+ this.enabled() &&
2643
+ (this._activeMode.handler.revertLayers(),
2644
+ L.Toolbar.prototype.disable.call(this))
2645
+ },
2646
+ _save: function () {
2647
+ ;(this._activeMode.handler.save(),
2648
+ this._activeMode && this._activeMode.handler.disable())
2649
+ },
2650
+ _clearAllLayers: function () {
2651
+ ;(this._activeMode.handler.removeAllLayers(),
2652
+ this._activeMode && this._activeMode.handler.disable())
2653
+ },
2654
+ _checkDisabled: function () {
2655
+ var t,
2656
+ e = this.options.featureGroup,
2657
+ i = 0 !== e.getLayers().length
2658
+ ;(this.options.edit &&
2659
+ ((t = this._modes[L.EditToolbar.Edit.TYPE].button),
2660
+ i
2661
+ ? L.DomUtil.removeClass(t, 'leaflet-disabled')
2662
+ : L.DomUtil.addClass(t, 'leaflet-disabled'),
2663
+ t.setAttribute(
2664
+ 'title',
2665
+ i
2666
+ ? L.drawLocal.edit.toolbar.buttons.edit
2667
+ : L.drawLocal.edit.toolbar.buttons.editDisabled
2668
+ )),
2669
+ this.options.remove &&
2670
+ ((t = this._modes[L.EditToolbar.Delete.TYPE].button),
2671
+ i
2672
+ ? L.DomUtil.removeClass(t, 'leaflet-disabled')
2673
+ : L.DomUtil.addClass(t, 'leaflet-disabled'),
2674
+ t.setAttribute(
2675
+ 'title',
2676
+ i
2677
+ ? L.drawLocal.edit.toolbar.buttons.remove
2678
+ : L.drawLocal.edit.toolbar.buttons.removeDisabled
2679
+ )))
2680
+ }
2681
+ })),
2682
+ (L.EditToolbar.Edit = L.Handler.extend({
2683
+ statics: { TYPE: 'edit' },
2684
+ initialize: function (t, e) {
2685
+ if (
2686
+ (L.Handler.prototype.initialize.call(this, t),
2687
+ L.setOptions(this, e),
2688
+ (this._featureGroup = e.featureGroup),
2689
+ !(this._featureGroup instanceof L.FeatureGroup))
2690
+ )
2691
+ throw new Error('options.featureGroup must be a L.FeatureGroup')
2692
+ ;((this._uneditedLayerProps = {}),
2693
+ (this.type = L.EditToolbar.Edit.TYPE))
2694
+ var i = L.version.split('.')
2695
+ 1 === parseInt(i[0], 10) && parseInt(i[1], 10) >= 2
2696
+ ? L.EditToolbar.Edit.include(L.Evented.prototype)
2697
+ : L.EditToolbar.Edit.include(L.Mixin.Events)
2698
+ },
2699
+ enable: function () {
2700
+ !this._enabled &&
2701
+ this._hasAvailableLayers() &&
2702
+ (this.fire('enabled', { handler: this.type }),
2703
+ this._map.fire(L.Draw.Event.EDITSTART, { handler: this.type }),
2704
+ L.Handler.prototype.enable.call(this),
2705
+ this._featureGroup
2706
+ .on('layeradd', this._enableLayerEdit, this)
2707
+ .on('layerremove', this._disableLayerEdit, this))
2708
+ },
2709
+ disable: function () {
2710
+ this._enabled &&
2711
+ (this._featureGroup
2712
+ .off('layeradd', this._enableLayerEdit, this)
2713
+ .off('layerremove', this._disableLayerEdit, this),
2714
+ L.Handler.prototype.disable.call(this),
2715
+ this._map.fire(L.Draw.Event.EDITSTOP, { handler: this.type }),
2716
+ this.fire('disabled', { handler: this.type }))
2717
+ },
2718
+ addHooks: function () {
2719
+ var t = this._map
2720
+ t &&
2721
+ (t.getContainer().focus(),
2722
+ this._featureGroup.eachLayer(this._enableLayerEdit, this),
2723
+ (this._tooltip = new L.Draw.Tooltip(this._map)),
2724
+ this._tooltip.updateContent({
2725
+ text: L.drawLocal.edit.handlers.edit.tooltip.text,
2726
+ subtext: L.drawLocal.edit.handlers.edit.tooltip.subtext
2727
+ }),
2728
+ (t._editTooltip = this._tooltip),
2729
+ this._updateTooltip(),
2730
+ this._map
2731
+ .on('mousemove', this._onMouseMove, this)
2732
+ .on('touchmove', this._onMouseMove, this)
2733
+ .on('MSPointerMove', this._onMouseMove, this)
2734
+ .on(L.Draw.Event.EDITVERTEX, this._updateTooltip, this))
2735
+ },
2736
+ removeHooks: function () {
2737
+ this._map &&
2738
+ (this._featureGroup.eachLayer(this._disableLayerEdit, this),
2739
+ (this._uneditedLayerProps = {}),
2740
+ this._tooltip.dispose(),
2741
+ (this._tooltip = null),
2742
+ this._map
2743
+ .off('mousemove', this._onMouseMove, this)
2744
+ .off('touchmove', this._onMouseMove, this)
2745
+ .off('MSPointerMove', this._onMouseMove, this)
2746
+ .off(L.Draw.Event.EDITVERTEX, this._updateTooltip, this))
2747
+ },
2748
+ revertLayers: function () {
2749
+ this._featureGroup.eachLayer(function (t) {
2750
+ this._revertLayer(t)
2751
+ }, this)
2752
+ },
2753
+ save: function () {
2754
+ var t = new L.LayerGroup()
2755
+ ;(this._featureGroup.eachLayer(function (e) {
2756
+ e.edited && (t.addLayer(e), (e.edited = !1))
2757
+ }),
2758
+ this._map.fire(L.Draw.Event.EDITED, { layers: t }))
2759
+ },
2760
+ _backupLayer: function (t) {
2761
+ var e = L.Util.stamp(t)
2762
+ this._uneditedLayerProps[e] ||
2763
+ (t instanceof L.Polyline ||
2764
+ t instanceof L.Polygon ||
2765
+ t instanceof L.Rectangle
2766
+ ? (this._uneditedLayerProps[e] = {
2767
+ latlngs: L.LatLngUtil.cloneLatLngs(t.getLatLngs())
2768
+ })
2769
+ : t instanceof L.Circle
2770
+ ? (this._uneditedLayerProps[e] = {
2771
+ latlng: L.LatLngUtil.cloneLatLng(t.getLatLng()),
2772
+ radius: t.getRadius()
2773
+ })
2774
+ : (t instanceof L.Marker || t instanceof L.CircleMarker) &&
2775
+ (this._uneditedLayerProps[e] = {
2776
+ latlng: L.LatLngUtil.cloneLatLng(t.getLatLng())
2777
+ }))
2778
+ },
2779
+ _getTooltipText: function () {
2780
+ return {
2781
+ text: L.drawLocal.edit.handlers.edit.tooltip.text,
2782
+ subtext: L.drawLocal.edit.handlers.edit.tooltip.subtext
2783
+ }
2784
+ },
2785
+ _updateTooltip: function () {
2786
+ this._tooltip.updateContent(this._getTooltipText())
2787
+ },
2788
+ _revertLayer: function (t) {
2789
+ var e = L.Util.stamp(t)
2790
+ ;((t.edited = !1),
2791
+ this._uneditedLayerProps.hasOwnProperty(e) &&
2792
+ (t instanceof L.Polyline ||
2793
+ t instanceof L.Polygon ||
2794
+ t instanceof L.Rectangle
2795
+ ? t.setLatLngs(this._uneditedLayerProps[e].latlngs)
2796
+ : t instanceof L.Circle
2797
+ ? (t.setLatLng(this._uneditedLayerProps[e].latlng),
2798
+ t.setRadius(this._uneditedLayerProps[e].radius))
2799
+ : (t instanceof L.Marker || t instanceof L.CircleMarker) &&
2800
+ t.setLatLng(this._uneditedLayerProps[e].latlng),
2801
+ t.fire('revert-edited', { layer: t })))
2802
+ },
2803
+ _enableLayerEdit: function (t) {
2804
+ var e,
2805
+ i,
2806
+ o = t.layer || t.target || t
2807
+ ;(this._backupLayer(o),
2808
+ this.options.poly &&
2809
+ ((i = L.Util.extend({}, this.options.poly)), (o.options.poly = i)),
2810
+ this.options.selectedPathOptions &&
2811
+ ((e = L.Util.extend({}, this.options.selectedPathOptions)),
2812
+ e.maintainColor &&
2813
+ ((e.color = o.options.color),
2814
+ (e.fillColor = o.options.fillColor)),
2815
+ (o.options.original = L.extend({}, o.options)),
2816
+ (o.options.editing = e)),
2817
+ o instanceof L.Marker
2818
+ ? (o.editing && o.editing.enable(),
2819
+ o.dragging.enable(),
2820
+ o
2821
+ .on('dragend', this._onMarkerDragEnd)
2822
+ .on('touchmove', this._onTouchMove, this)
2823
+ .on('MSPointerMove', this._onTouchMove, this)
2824
+ .on('touchend', this._onMarkerDragEnd, this)
2825
+ .on('MSPointerUp', this._onMarkerDragEnd, this))
2826
+ : o.editing.enable())
2827
+ },
2828
+ _disableLayerEdit: function (t) {
2829
+ var e = t.layer || t.target || t
2830
+ ;((e.edited = !1),
2831
+ e.editing && e.editing.disable(),
2832
+ delete e.options.editing,
2833
+ delete e.options.original,
2834
+ this._selectedPathOptions &&
2835
+ (e instanceof L.Marker
2836
+ ? this._toggleMarkerHighlight(e)
2837
+ : (e.setStyle(e.options.previousOptions),
2838
+ delete e.options.previousOptions)),
2839
+ e instanceof L.Marker
2840
+ ? (e.dragging.disable(),
2841
+ e
2842
+ .off('dragend', this._onMarkerDragEnd, this)
2843
+ .off('touchmove', this._onTouchMove, this)
2844
+ .off('MSPointerMove', this._onTouchMove, this)
2845
+ .off('touchend', this._onMarkerDragEnd, this)
2846
+ .off('MSPointerUp', this._onMarkerDragEnd, this))
2847
+ : e.editing.disable())
2848
+ },
2849
+ _onMouseMove: function (t) {
2850
+ this._tooltip.updatePosition(t.latlng)
2851
+ },
2852
+ _onMarkerDragEnd: function (t) {
2853
+ var e = t.target
2854
+ ;((e.edited = !0), this._map.fire(L.Draw.Event.EDITMOVE, { layer: e }))
2855
+ },
2856
+ _onTouchMove: function (t) {
2857
+ var e = t.originalEvent.changedTouches[0],
2858
+ i = this._map.mouseEventToLayerPoint(e),
2859
+ o = this._map.layerPointToLatLng(i)
2860
+ t.target.setLatLng(o)
2861
+ },
2862
+ _hasAvailableLayers: function () {
2863
+ return 0 !== this._featureGroup.getLayers().length
2864
+ }
2865
+ })),
2866
+ (L.EditToolbar.Delete = L.Handler.extend({
2867
+ statics: { TYPE: 'remove' },
2868
+ initialize: function (t, e) {
2869
+ if (
2870
+ (L.Handler.prototype.initialize.call(this, t),
2871
+ L.Util.setOptions(this, e),
2872
+ (this._deletableLayers = this.options.featureGroup),
2873
+ !(this._deletableLayers instanceof L.FeatureGroup))
2874
+ )
2875
+ throw new Error('options.featureGroup must be a L.FeatureGroup')
2876
+ this.type = L.EditToolbar.Delete.TYPE
2877
+ var i = L.version.split('.')
2878
+ 1 === parseInt(i[0], 10) && parseInt(i[1], 10) >= 2
2879
+ ? L.EditToolbar.Delete.include(L.Evented.prototype)
2880
+ : L.EditToolbar.Delete.include(L.Mixin.Events)
2881
+ },
2882
+ enable: function () {
2883
+ !this._enabled &&
2884
+ this._hasAvailableLayers() &&
2885
+ (this.fire('enabled', { handler: this.type }),
2886
+ this._map.fire(L.Draw.Event.DELETESTART, { handler: this.type }),
2887
+ L.Handler.prototype.enable.call(this),
2888
+ this._deletableLayers
2889
+ .on('layeradd', this._enableLayerDelete, this)
2890
+ .on('layerremove', this._disableLayerDelete, this))
2891
+ },
2892
+ disable: function () {
2893
+ this._enabled &&
2894
+ (this._deletableLayers
2895
+ .off('layeradd', this._enableLayerDelete, this)
2896
+ .off('layerremove', this._disableLayerDelete, this),
2897
+ L.Handler.prototype.disable.call(this),
2898
+ this._map.fire(L.Draw.Event.DELETESTOP, { handler: this.type }),
2899
+ this.fire('disabled', { handler: this.type }))
2900
+ },
2901
+ addHooks: function () {
2902
+ var t = this._map
2903
+ t &&
2904
+ (t.getContainer().focus(),
2905
+ this._deletableLayers.eachLayer(this._enableLayerDelete, this),
2906
+ (this._deletedLayers = new L.LayerGroup()),
2907
+ (this._tooltip = new L.Draw.Tooltip(this._map)),
2908
+ this._tooltip.updateContent({
2909
+ text: L.drawLocal.edit.handlers.remove.tooltip.text
2910
+ }),
2911
+ this._map.on('mousemove', this._onMouseMove, this))
2912
+ },
2913
+ removeHooks: function () {
2914
+ this._map &&
2915
+ (this._deletableLayers.eachLayer(this._disableLayerDelete, this),
2916
+ (this._deletedLayers = null),
2917
+ this._tooltip.dispose(),
2918
+ (this._tooltip = null),
2919
+ this._map.off('mousemove', this._onMouseMove, this))
2920
+ },
2921
+ revertLayers: function () {
2922
+ this._deletedLayers.eachLayer(function (t) {
2923
+ ;(this._deletableLayers.addLayer(t),
2924
+ t.fire('revert-deleted', { layer: t }))
2925
+ }, this)
2926
+ },
2927
+ save: function () {
2928
+ this._map.fire(L.Draw.Event.DELETED, { layers: this._deletedLayers })
2929
+ },
2930
+ removeAllLayers: function () {
2931
+ ;(this._deletableLayers.eachLayer(function (t) {
2932
+ this._removeLayer({ layer: t })
2933
+ }, this),
2934
+ this.save())
2935
+ },
2936
+ _enableLayerDelete: function (t) {
2937
+ ;(t.layer || t.target || t).on('click', this._removeLayer, this)
2938
+ },
2939
+ _disableLayerDelete: function (t) {
2940
+ var e = t.layer || t.target || t
2941
+ ;(e.off('click', this._removeLayer, this),
2942
+ this._deletedLayers.removeLayer(e))
2943
+ },
2944
+ _removeLayer: function (t) {
2945
+ var e = t.layer || t.target || t
2946
+ ;(this._deletableLayers.removeLayer(e),
2947
+ this._deletedLayers.addLayer(e),
2948
+ e.fire('deleted'))
2949
+ },
2950
+ _onMouseMove: function (t) {
2951
+ this._tooltip.updatePosition(t.latlng)
2952
+ },
2953
+ _hasAvailableLayers: function () {
2954
+ return 0 !== this._deletableLayers.getLayers().length
2955
+ }
2956
+ })))
2957
+ })(window, document)