From 1883c95da4b79da03365e8e0eea6b917e6cb4f10 Mon Sep 17 00:00:00 2001 From: 徐旺旺 <11530253@qq.com> Date: 星期五, 26 二月 2021 12:11:01 +0800 Subject: [PATCH] 修改图层控制 --- src/components/plugin/PathDashFlow.js | 54 +++++++++++++++++++++++++++--------------------------- 1 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/components/plugin/PathDashFlow.js b/src/components/plugin/PathDashFlow.js index 52792fc..1432190 100644 --- a/src/components/plugin/PathDashFlow.js +++ b/src/components/plugin/PathDashFlow.js @@ -1,43 +1,43 @@ // @class PolyLine import * as L from 'leaflet' -let DashFlow = () => { - L.Path.mergeOptions({ - // @option dashSpeed: Number - // The speed of the dash array, in pixels per second - dashSpeed: 0 - }) +const DashFlow = () => { + L.Path.mergeOptions({ + // @option dashSpeed: Number + // The speed of the dash array, in pixels per second + dashSpeed: 0 + }) - var _originalBeforeAdd = L.Path.prototype.beforeAdd + var _originalBeforeAdd = L.Path.prototype.beforeAdd - L.Path.include({ + L.Path.include({ - beforeAdd: function(map) { - _originalBeforeAdd.bind(this)(map) + beforeAdd: function (map) { + _originalBeforeAdd.bind(this)(map) - if (this.options.dashSpeed) { - this._lastDashFrame = performance.now() - this._dashFrame = L.Util.requestAnimFrame(this._onDashFrame.bind(this)) - } - }, + if (this.options.dashSpeed) { + this._lastDashFrame = performance.now() + this._dashFrame = L.Util.requestAnimFrame(this._onDashFrame.bind(this)) + } + }, - _onDashFrame: function() { - if (!this._renderer) { - return - } + _onDashFrame: function () { + if (!this._renderer) { + return + } - var now = performance.now() - var dashOffsetDelta = (now - this._lastDashFrame) * this.options.dashSpeed / 1000 + var now = performance.now() + var dashOffsetDelta = (now - this._lastDashFrame) * this.options.dashSpeed / 1000 - this.options.dashOffset = Number(this.options.dashOffset || 0) + dashOffsetDelta - this._renderer._updateStyle(this) + this.options.dashOffset = Number(this.options.dashOffset || 0) + dashOffsetDelta + this._renderer._updateStyle(this) - this._lastDashFrame = performance.now() + this._lastDashFrame = performance.now() - this._dashFrame = L.Util.requestAnimFrame(this._onDashFrame.bind(this)) - } + this._dashFrame = L.Util.requestAnimFrame(this._onDashFrame.bind(this)) + } - }) + }) } export default { DashFlow } -- Gitblit v1.8.0