fix Canvas layer redawing

This commit is contained in:
Vladimir Agafonkin 2014-01-03 20:14:24 +02:00
parent b01126d9fb
commit be85ff304c
4 changed files with 18 additions and 3 deletions

View File

@ -37,13 +37,16 @@
var circle = L.circle([35, 0], 700000, {color: 'green', renderer: canvas}).addTo(map).bindPopup('Hello Circle'); 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!'); 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); map.setView([36, 52], 3);
var layersControl = new L.Control.Layers({ var layersControl = new L.Control.Layers({
}, { }, {
'poly': poly, 'poly': poly,
'path': path, 'path': path,
// 'rect': rect,
'circle': circle, 'circle': circle,
'circleMarker': circleMarker, 'circleMarker': circleMarker,
'canvas': canvas, 'canvas': canvas,

View File

@ -60,6 +60,14 @@ L.Canvas = L.Renderer.extend({
this._requestRedraw(layer); this._requestRedraw(layer);
}, },
_updatePath: function (layer) {
this._redrawBounds = layer._pxBounds;
this._draw(true);
layer._project();
this._draw();
this._redrawBounds = null;
},
_updateStyle: function (layer) { _updateStyle: function (layer) {
this._requestRedraw(layer); this._requestRedraw(layer);
}, },

View File

@ -45,8 +45,7 @@ L.Path = L.Layer.extend({
redraw: function () { redraw: function () {
if (this._map) { if (this._map) {
this._project(); this._renderer._updatePath(this);
this._update();
} }
return this; return this;
}, },

View File

@ -69,6 +69,11 @@ L.SVG = L.Renderer.extend({
delete this._paths[L.stamp(path)]; delete this._paths[L.stamp(path)];
}, },
_updatePath: function (layer) {
layer._project();
layer._update();
},
_updateStyle: function (layer) { _updateStyle: function (layer) {
var path = layer._path, var path = layer._path,
options = layer.options; options = layer.options;