派生自 wuyushui/SewerAndRainNetwork

YANGDL
2021-01-05 1820aef3fb5c926664de1d4d484f64a5c9ba7099
src/components/plugin/PathDrag.js
@@ -7,17 +7,17 @@
        initialize: function(path) {
            this._path = path
            this._canvas = (path._map.getRenderer(path) instanceof L.Canvas)
            let element = this._canvas ? this._path._map.getRenderer(this._path)._container : this._path._path
      const element = this._canvas ? this._path._map.getRenderer(this._path)._container : this._path._path
            L.Draggable.prototype.initialize.call(this, element, element, true)
        },
        _updatePosition: function() {
            let e = { originalEvent: this._lastEvent }
      const e = { originalEvent: this._lastEvent }
            this.fire('drag', e)
        },
        _onDown: function(e) {
            let first = e.touches ? e.touches[0] : e
      const first = e.touches ? e.touches[0] : e
            this._startPoint = new L.Point(first.clientX, first.clientY)
            if (this._canvas && !this._path._containsPoint(this._path._map.mouseEventToLayerPoint(first))) {
                return
@@ -67,10 +67,10 @@
        },
        _onDrag: function(e) {
            let path = this._path
            let event = (e.originalEvent.touches && e.originalEvent.touches.length === 1 ? e.originalEvent.touches[0] : e.originalEvent)
            let newPoint = L.point(event.clientX, event.clientY)
            let latlng = path._map.layerPointToLatLng(newPoint)
      const path = this._path
      const event = (e.originalEvent.touches && e.originalEvent.touches.length === 1 ? e.originalEvent.touches[0] : e.originalEvent)
      const newPoint = L.point(event.clientX, event.clientY)
      const latlng = path._map.layerPointToLatLng(newPoint)
            this._offset = newPoint.subtract(this._startPoint)
            this._startPoint = newPoint
@@ -93,14 +93,14 @@
        latLngToLayerPoint: function(latlng) {
            // Same as map.latLngToLayerPoint, but without the round().
            let projectedPoint = this._path._map.project(L.latLng(latlng))
      const projectedPoint = this._path._map.project(L.latLng(latlng))
            return projectedPoint._subtract(this._path._map.getPixelOrigin())
        },
        updateLatLng: function(latlng) {
            let oldPoint = this.latLngToLayerPoint(latlng)
      const oldPoint = this.latLngToLayerPoint(latlng)
            oldPoint._add(this._offset)
            let newLatLng = this._path._map.layerPointToLatLng(oldPoint)
      const newLatLng = this._path._map.layerPointToLatLng(oldPoint)
            latlng.lat = newLatLng.lat
            latlng.lng = newLatLng.lng
        },
@@ -118,7 +118,7 @@
        eachLatLng: function(callback, context) {
            context = context || this
            let loop = function(latlngs) {
      const loop = function (latlngs) {
                for (let i = 0; i < latlngs.length; i++) {
                    if (L.Util.isArray(latlngs[i])) loop(latlngs[i])
                    else callback.call(context, latlngs[i])