From cfb52200f39d0c659eb884a1df331dd997af7e72 Mon Sep 17 00:00:00 2001
From: YANGDL <114714267@qq.com>
Date: 星期三, 10 三月 2021 09:06:55 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 src/components/plugin/Editable.js |  154 ++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 114 insertions(+), 40 deletions(-)

diff --git a/src/components/plugin/Editable.js b/src/components/plugin/Editable.js
index d86dbc0..943fdcd 100644
--- a/src/components/plugin/Editable.js
+++ b/src/components/plugin/Editable.js
@@ -348,6 +348,26 @@
         circle.enableEdit(this.map).startDrawing()
         return circle
       },
+      // 鏂囧瓧鏍囨敞
+      startText: function (latlng, options) {
+        latlng = latlng || this.map.getCenter().clone()
+        const markerBuilding = this.createMarker(latlng, options).bindTooltip('闂鏍囨敞鍐呭', {
+          offset: [0, 0],
+          permanent: true,
+          direction: 'top',
+          className: 'anim-tooltip'
+        })
+        markerBuilding.enableEdit(this.map).startDrawing()
+        return markerBuilding
+      },
+
+      // 鍥炬爣鏍囨敞
+      startIcon: function (latlng, options) {
+        latlng = latlng || this.map.getCenter().clone()
+        const icon = this.createMarker(latlng, options)
+        icon.enableEdit(this.map).startDrawing()
+        return icon
+      },
 
       startHole: function (editor, latlng) {
         editor.newHole(latlng)
@@ -565,7 +585,10 @@
         const next = this.getNext() // Compute before changing latlng
         this.latlngs.splice(this.getIndex(), 1)
         this.editor.editLayer.removeLayer(this)
-        this.editor.onVertexDeleted({ latlng: this.latlng, vertex: this })
+        this.editor.onVertexDeleted({
+          latlng: this.latlng,
+          vertex: this
+        })
         if (!this.latlngs.length) this.editor.deleteShape(this.latlngs)
         if (next) next.resetMiddleMarker()
         this.editor.refresh()
@@ -636,8 +659,9 @@
       continue: function () {
         if (!this.editor.continueBackward) return // Only for PolylineEditor
         const index = this.getIndex()
-        if (index === 0) this.editor.continueBackward(this.latlngs)
-        else if (index === this.getLastIndex()) this.editor.continueForward(this.latlngs)
+        if (index === 0) {
+          this.editor.continueBackward(this.latlngs)
+        } else if (index === this.getLastIndex()) this.editor.continueForward(this.latlngs)
       }
 
     })
@@ -675,8 +699,11 @@
         const leftPoint = this._map.latLngToContainerPoint(this.left.latlng)
         const rightPoint = this._map.latLngToContainerPoint(this.right.latlng)
         const size = L.point(this.options.icon.options.iconSize)
-        if (leftPoint.distanceTo(rightPoint) < size.x * 3) this.hide()
-        else this.show()
+        if (leftPoint.distanceTo(rightPoint) < size.x * 3) {
+          this.hide()
+        } else {
+          this.show()
+        }
       },
 
       show: function () {
@@ -780,8 +807,11 @@
       // 馃崅method enable(): this
       // Set up the drawing tools for the feature to be editable.
       addHooks: function () {
-        if (this.isConnected()) this.onFeatureAdd()
-        else this.feature.once('add', this.onFeatureAdd, this)
+        if (this.isConnected()) {
+          this.onFeatureAdd()
+        } else {
+          this.feature.once('add', this.onFeatureAdd, this)
+        }
         this.onEnable()
         this.feature.on(this._getEvents(), this)
       },
@@ -1030,8 +1060,11 @@
       initVertexMarkers: function (latlngs) {
         if (!this.enabled()) return
         latlngs = latlngs || this.getLatLngs()
-        if (isFlat(latlngs)) this.addVertexMarkers(latlngs)
-        else for (let i = 0; i < latlngs.length; i++) this.initVertexMarkers(latlngs[i])
+        if (isFlat(latlngs)) {
+          this.addVertexMarkers(latlngs)
+        } else {
+          for (let i = 0; i < latlngs.length; i++) this.initVertexMarkers(latlngs[i])
+        }
       },
 
       getLatLngs: function () {
@@ -1054,7 +1087,10 @@
         // 馃崅section Vertex events
         // 馃崅event editable:vertex:new: VertexEvent
         // Fired when a new vertex is created.
-        this.fireAndForward('editable:vertex:new', { latlng: vertex.latlng, vertex: vertex })
+        this.fireAndForward('editable:vertex:new', {
+          latlng: vertex.latlng,
+          vertex: vertex
+        })
       },
 
       addVertexMarkers: function (latlngs) {
@@ -1253,8 +1289,11 @@
       },
 
       addLatLng: function (latlng) {
-        if (this._drawing === L.Editable.FORWARD) this._drawnLatLngs.push(latlng)
-        else this._drawnLatLngs.unshift(latlng)
+        if (this._drawing === L.Editable.FORWARD) {
+          this._drawnLatLngs.push(latlng)
+        } else {
+          this._drawnLatLngs.unshift(latlng)
+        }
         this.feature._bounds.extend(latlng)
         const vertex = this.addVertexMarker(latlng, this._drawnLatLngs)
         this.onNewVertex(vertex)
@@ -1277,8 +1316,11 @@
       // Programmatically add a point while drawing.
       push: function (latlng) {
         if (!latlng) return console.error('L.Editable.PathEditor.push expect a valid latlng as parameter')
-        if (this._drawing === L.Editable.FORWARD) this.newPointForward(latlng)
-        else this.newPointBackward(latlng)
+        if (this._drawing === L.Editable.FORWARD) {
+          this.newPointForward(latlng)
+        } else {
+          this.newPointBackward(latlng)
+        }
       },
 
       removeLatLng: function (latlng) {
@@ -1291,18 +1333,27 @@
       pop: function () {
         if (this._drawnLatLngs.length <= 1) return
         let latlng
-        if (this._drawing === L.Editable.FORWARD) latlng = this._drawnLatLngs[this._drawnLatLngs.length - 1]
-        else latlng = this._drawnLatLngs[0]
+        if (this._drawing === L.Editable.FORWARD) {
+          latlng = this._drawnLatLngs[this._drawnLatLngs.length - 1]
+        } else {
+          latlng = this._drawnLatLngs[0]
+        }
         this.removeLatLng(latlng)
-        if (this._drawing === L.Editable.FORWARD) this.tools.anchorForwardLineGuide(this._drawnLatLngs[this._drawnLatLngs.length - 1])
-        else this.tools.anchorForwardLineGuide(this._drawnLatLngs[0])
+        if (this._drawing === L.Editable.FORWARD) {
+          this.tools.anchorForwardLineGuide(this._drawnLatLngs[this._drawnLatLngs.length - 1])
+        } else {
+          this.tools.anchorForwardLineGuide(this._drawnLatLngs[0])
+        }
         return latlng
       },
 
       processDrawingClick: function (e) {
         if (e.vertex && e.vertex.editor === this) return
-        if (this._drawing === L.Editable.FORWARD) this.newPointForward(e.latlng)
-        else this.newPointBackward(e.latlng)
+        if (this._drawing === L.Editable.FORWARD) {
+          this.newPointForward(e.latlng)
+        } else {
+          this.newPointBackward(e.latlng)
+        }
         this.fireAndForward('editable:drawing:clicked', e)
       },
 
@@ -1375,8 +1426,9 @@
         }
         if (latlngs === shape) return inplaceDelete(latlngs, shape)
         for (let i = 0; i < latlngs.length; i++) {
-          if (latlngs[i] === shape) return spliceDelete(latlngs, shape)
-          else if (latlngs[i].indexOf(shape) !== -1) return spliceDelete(latlngs[i], shape)
+          if (latlngs[i] === shape) {
+            return spliceDelete(latlngs, shape)
+          } else if (latlngs[i].indexOf(shape) !== -1) return spliceDelete(latlngs[i], shape)
         }
       },
 
@@ -1464,8 +1516,11 @@
 
       getDefaultLatLngs: function (latlngs) {
         latlngs = latlngs || this.feature._latlngs
-        if (!latlngs.length || latlngs[0] instanceof L.LatLng) return latlngs
-        else return this.getDefaultLatLngs(latlngs[0])
+        if (!latlngs.length || latlngs[0] instanceof L.LatLng) {
+          return latlngs
+        } else {
+          return this.getDefaultLatLngs(latlngs[0])
+        }
       },
 
       ensureMulti: function () {
@@ -1485,8 +1540,9 @@
       },
 
       formatShape: function (shape) {
-        if (isFlat(shape)) return shape
-        else if (shape[0]) return this.formatShape(shape[0])
+        if (isFlat(shape)) {
+          return shape
+        } else if (shape[0]) return this.formatShape(shape[0])
       },
 
       // 馃崅method splitShape(latlngs?: Array, index: int)
@@ -1575,8 +1631,11 @@
         // [[1, 2], [3, 4]] => must be nested
         // [] => must be nested
         // [[]] => is already nested
-        if (isFlat(shape) && (!shape[0] || shape[0].length !== 0)) return [shape]
-        else return shape
+        if (isFlat(shape) && (!shape[0] || shape[0].length !== 0)) {
+          return [shape]
+        } else {
+          return shape
+        }
       }
 
     })
@@ -1711,8 +1770,11 @@
       },
 
       onVertexMarkerDrag: function (e) {
-        if (e.vertex.getIndex() === 1) this.resize(e)
-        else this.updateResizeLatLng(e)
+        if (e.vertex.getIndex() === 1) {
+          this.resize(e)
+        } else {
+          this.updateResizeLatLng(e)
+        }
         L.Editable.PathEditor.prototype.onVertexMarkerDrag.call(this, e)
       },
 
@@ -1792,8 +1854,11 @@
       // 馃崅method toggleEdit()
       // Enable or disable editing, according to current status.
       toggleEdit: function () {
-        if (this.editEnabled()) this.disableEdit()
-        else this.enableEdit()
+        if (this.editEnabled()) {
+          this.disableEdit()
+        } else {
+          this.enableEdit()
+        }
       },
 
       _onEditableAdd: function () {
@@ -1814,9 +1879,13 @@
         // - latlngs is an array of arrays of latlngs, loop over
         let shape = null
         latlngs = latlngs || this._latlngs
-        if (!latlngs.length) return shape
-        else if (isFlat(latlngs) && this.isInLatLngs(latlng, latlngs)) shape = latlngs
-        else for (let i = 0; i < latlngs.length; i++) if (this.isInLatLngs(latlng, latlngs[i])) return latlngs[i]
+        if (!latlngs.length) {
+          return shape
+        } else if (isFlat(latlngs) && this.isInLatLngs(latlng, latlngs)) {
+          shape = latlngs
+        } else {
+          for (let i = 0; i < latlngs.length; i++) if (this.isInLatLngs(latlng, latlngs[i])) return latlngs[i]
+        }
         return shape
       },
 
@@ -1855,10 +1924,15 @@
         // - latlngs is an array of arrays of arrays, this is a multi, loop over
         let shape = null
         latlngs = latlngs || this._latlngs
-        if (!latlngs.length) return shape
-        else if (isFlat(latlngs) && this.isInLatLngs(latlng, latlngs)) shape = latlngs
-        else if (isFlat(latlngs[0]) && this.isInLatLngs(latlng, latlngs[0])) shape = latlngs
-        else for (let i = 0; i < latlngs.length; i++) if (this.isInLatLngs(latlng, latlngs[i][0])) return latlngs[i]
+        if (!latlngs.length) {
+          return shape
+        } else if (isFlat(latlngs) && this.isInLatLngs(latlng, latlngs)) {
+          shape = latlngs
+        } else if (isFlat(latlngs[0]) && this.isInLatLngs(latlng, latlngs[0])) {
+          shape = latlngs
+        } else {
+          for (let i = 0; i < latlngs.length; i++) if (this.isInLatLngs(latlng, latlngs[i][0])) return latlngs[i]
+        }
         return shape
       },
 
@@ -1874,7 +1948,7 @@
           l2 = latlngs[k]
 
           if (((l1.lat > l.lat) !== (l2.lat > l.lat)) &&
-                        (l.lng < (l2.lng - l1.lng) * (l.lat - l1.lat) / (l2.lat - l1.lat) + l1.lng)) {
+            (l.lng < (l2.lng - l1.lng) * (l.lat - l1.lat) / (l2.lat - l1.lat) + l1.lng)) {
             inside = !inside
           }
         }

--
Gitblit v1.8.0