From be85ff304c0603c2cd52e4738b3e1a2902b3559f Mon Sep 17 00:00:00 2001 From: Vladimir Agafonkin Date: Fri, 3 Jan 2014 20:14:24 +0200 Subject: [PATCH] fix Canvas layer redawing --- debug/vector/vector2.html | 5 ++++- src/layer/vector/Canvas.js | 8 ++++++++ src/layer/vector/Path.js | 3 +-- src/layer/vector/SVG.js | 5 +++++ 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/debug/vector/vector2.html b/debug/vector/vector2.html index 9840e610..84a9fae3 100644 --- a/debug/vector/vector2.html +++ b/debug/vector/vector2.html @@ -37,13 +37,16 @@ var circle = L.circle([35, 0], 700000, {color: 'green', renderer: canvas}).addTo(map).bindPopup('Hello Circle'); var circleMarker = L.circleMarker([35, 30], {color: 'magenta', radius: 30}).addTo(map).bindPopup('Happy New Year!'); + map.on('mousemove', function (e) { + circle.setLatLng(e.latlng); + }); + map.setView([36, 52], 3); var layersControl = new L.Control.Layers({ }, { 'poly': poly, 'path': path, - // 'rect': rect, 'circle': circle, 'circleMarker': circleMarker, 'canvas': canvas, diff --git a/src/layer/vector/Canvas.js b/src/layer/vector/Canvas.js index 64a46110..3b7655ae 100644 --- a/src/layer/vector/Canvas.js +++ b/src/layer/vector/Canvas.js @@ -60,6 +60,14 @@ L.Canvas = L.Renderer.extend({ this._requestRedraw(layer); }, + _updatePath: function (layer) { + this._redrawBounds = layer._pxBounds; + this._draw(true); + layer._project(); + this._draw(); + this._redrawBounds = null; + }, + _updateStyle: function (layer) { this._requestRedraw(layer); }, diff --git a/src/layer/vector/Path.js b/src/layer/vector/Path.js index b52f778e..16c5defd 100644 --- a/src/layer/vector/Path.js +++ b/src/layer/vector/Path.js @@ -45,8 +45,7 @@ L.Path = L.Layer.extend({ redraw: function () { if (this._map) { - this._project(); - this._update(); + this._renderer._updatePath(this); } return this; }, diff --git a/src/layer/vector/SVG.js b/src/layer/vector/SVG.js index 98fa1504..0c337d3d 100644 --- a/src/layer/vector/SVG.js +++ b/src/layer/vector/SVG.js @@ -69,6 +69,11 @@ L.SVG = L.Renderer.extend({ delete this._paths[L.stamp(path)]; }, + _updatePath: function (layer) { + layer._project(); + layer._update(); + }, + _updateStyle: function (layer) { var path = layer._path, options = layer.options;