From 293eeb7735794babc6aa51ad45f8942b4802eab2 Mon Sep 17 00:00:00 2001 From: menghan Date: Thu, 9 Jun 2022 15:29:15 +0800 Subject: [PATCH] update position when layer mount --- L.CanvasLayer.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/L.CanvasLayer.js b/L.CanvasLayer.js index 2acfe6d..57b13ca 100644 --- a/L.CanvasLayer.js +++ b/L.CanvasLayer.js @@ -49,9 +49,12 @@ L.CanvasLayer = (L.Layer ? L.Layer : L.Class).extend({ this._canvas.height = resizeEvent.newSize.y; }, //------------------------------------------------------------- - _onLayerDidMove: function () { + _updatePosition: function () { var topLeft = this._map.containerPointToLayerPoint([0, 0]); - L.DomUtil.setPosition(this._canvas, topLeft); + L.DomUtil.setPosition(this._canvas, topLeft); + }, + _onLayerDidMove: function () { + this._updatePosition() this.drawLayer(); }, //------------------------------------------------------------- @@ -86,7 +89,8 @@ L.CanvasLayer = (L.Layer ? L.Layer : L.Class).extend({ map.on(this.getEvents(),this); var del = this._delegate || this; - del.onLayerDidMount && del.onLayerDidMount(); // -- callback + del.onLayerDidMount && del.onLayerDidMount(); // -- callback\ + this._updatePosition(); this.needRedraw(); },