fix adding/removal of vectors and renderers

This commit is contained in:
Vladimir Agafonkin 2013-12-16 18:55:15 -05:00
parent f750b76e04
commit f4f8c06c75
4 changed files with 30 additions and 5 deletions

View File

@ -38,6 +38,18 @@
var circleMarker = L.circleMarker([35, 30], {color: 'magenta', radius: 30}).addTo(map);
map.setView([36, 52], 3);
var layersControl = new L.Control.Layers({
}, {
'poly': poly,
'path': path,
// 'rect': rect,
'circle': circle,
'circleMarker': circleMarker,
'canvas': canvas,
'svg': L.SVG.instance,
}, {collapsed: false});
map.addControl(layersControl);
</script>
</body>
</html>

View File

@ -15,6 +15,8 @@ L.Canvas = L.Renderer.extend({
this.getPane().appendChild(container);
this._update();
this.fire('redraw');
},
onRemove: function () {
@ -48,6 +50,9 @@ L.Canvas = L.Renderer.extend({
},
_initPath: function (layer) {
if (!layer._updatePath) {
debugger;
}
this.on('redraw', layer._updatePath, layer);
if (layer.options.clickable) {

View File

@ -48,10 +48,14 @@ L.CircleMarker = L.Path.extend({
_update: function () {
if (this._map) {
this._renderer._updateCircle(this);
this._updatePath();
}
},
_updatePath: function () {
this._renderer._updateCircle(this);
},
_empty: function () {
var b = this._renderer._bounds,
r = this._radius + (this.options.stroke ? this.options.weight / 2 : 0),

View File

@ -2,12 +2,16 @@
L.SVG = L.Renderer.extend({
onAdd: function () {
var container = this._container = L.SVG.create('svg');
var container = this._container;
if (!container) {
container = this._container = L.SVG.create('svg');
container.setAttribute('pointer-events', 'none');
if (this._zoomAnimated) {
L.DomUtil.addClass(container, 'leaflet-zoom-animated');
}
}
this.getPane().appendChild(container);
this._update();