diff --git a/debug/vector/vector2.html b/debug/vector/vector2.html index 8ecc6f81..6f1c093c 100644 --- a/debug/vector/vector2.html +++ b/debug/vector/vector2.html @@ -38,9 +38,9 @@ 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.on('mousemove', function (e) { + // circle.setLatLng(e.latlng); + // }); map.setView([36, 52], 3); @@ -51,7 +51,7 @@ 'circle': circle, 'circleMarker': circleMarker, 'canvas': canvas, - 'svg': L.SVG.instance, + 'svg': map._renderer, }, {collapsed: false}); map.addControl(layersControl); diff --git a/src/layer/vector/Canvas.js b/src/layer/vector/Canvas.js index aedee762..59580090 100644 --- a/src/layer/vector/Canvas.js +++ b/src/layer/vector/Canvas.js @@ -241,8 +241,6 @@ L.canvas = function (options) { return L.Browser.canvas ? new L.Canvas(options) : null; }; -L.Canvas.instance = L.canvas(); - L.Polyline.prototype._containsPoint = function (p, closed) { var i, j, k, len, len2, part, w = this._clickTolerance(); diff --git a/src/layer/vector/Renderer.js b/src/layer/vector/Renderer.js index 9b51e45e..d5300165 100644 --- a/src/layer/vector/Renderer.js +++ b/src/layer/vector/Renderer.js @@ -64,8 +64,11 @@ L.Renderer = L.Layer.extend({ L.Map.include({ // used by each vector layer to decide which renderer to use getRenderer: function (layer) { - var renderer = layer.options.renderer || this.options.renderer || - (L.SVG && L.SVG.instance) || (L.Canvas && L.Canvas.instance); + var renderer = layer.options.renderer || this.options.renderer || this._renderer; + + if (!renderer) { + renderer = this._renderer = (L.SVG && L.svg()) || (L.Canvas && L.canvas()); + } if (!this.hasLayer(renderer)) { this.addLayer(renderer); diff --git a/src/layer/vector/SVG.VML.js b/src/layer/vector/SVG.VML.js index 3ddd1e24..2cc1d244 100644 --- a/src/layer/vector/SVG.VML.js +++ b/src/layer/vector/SVG.VML.js @@ -132,6 +132,4 @@ if (L.Browser.vml) { }; } })(); - - L.SVG.instance = L.svg(); } diff --git a/src/layer/vector/SVG.js b/src/layer/vector/SVG.js index a141da32..b8768d2e 100644 --- a/src/layer/vector/SVG.js +++ b/src/layer/vector/SVG.js @@ -184,6 +184,3 @@ L.Browser.svg = !!(document.createElementNS && L.SVG.create('svg').createSVGRect L.svg = function (options) { return L.Browser.svg || L.Browser.vml ? new L.SVG(options) : null; }; - -// default instance to use when adding vectors to the map -L.SVG.instance = L.svg();