From 2d398b4fa805ba43a89311d955fbb6e47c540e6c Mon Sep 17 00:00:00 2001
From: YANGDL <114714267@qq.com>
Date: 星期五, 12 三月 2021 20:57:16 +0800
Subject: [PATCH] 修改了界面自适应

---
 src/components/plugin/Editable.js |  153 +++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 112 insertions(+), 41 deletions(-)

diff --git a/src/components/plugin/Editable.js b/src/components/plugin/Editable.js
index d86dbc0..bd287f5 100644
--- a/src/components/plugin/Editable.js
+++ b/src/components/plugin/Editable.js
@@ -298,7 +298,6 @@
       connectCreatedToMap: function (layer) {
         return this.featuresLayer.addLayer(layer)
       },
-
       // 馃崅method startPolyline(latlng: L.LatLng, options: hash): L.Polyline
       // Start drawing a Polyline. If `latlng` is given, a first point will be added. In any case, continuing on user click.
       // If `options` is given, it will be passed to the Polyline class constructor.
@@ -306,6 +305,16 @@
         const line = this.createPolyline([], options)
         line.enableEdit(this.map).newShape(latlng)
         return line
+      },
+      // 绠ご鏍囩粯
+      startPolylineArrow: function (latlng, options) {
+        const lineArrow = this.createPolyline([], {
+          color: 'black',
+          weight: 3,
+          opacity: 1.0
+        })
+        lineArrow.enableEdit(this.map).newShape(latlng)
+        return lineArrow
       },
 
       // 馃崅method startPolygon(latlng: L.LatLng, options: hash): L.Polygon
@@ -347,6 +356,14 @@
         const circle = this.createCircle(latlng, options)
         circle.enableEdit(this.map).startDrawing()
         return circle
+      },
+
+      // 鍥炬爣鏍囨敞
+      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) {
@@ -565,7 +582,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 +656,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 +696,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 +804,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 +1057,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 +1084,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 +1286,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 +1313,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 +1330,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 +1423,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 +1513,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 +1537,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 +1628,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 +1767,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 +1851,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 +1876,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 +1921,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 +1945,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