diff --git a/debug/vector/vector-canvas.html b/debug/vector/vector-canvas.html index c1749115..f89c2c94 100644 --- a/debug/vector/vector-canvas.html +++ b/debug/vector/vector-canvas.html @@ -83,6 +83,11 @@ }); group.addLayer(polygon); + var line = new L.Polyline([h1, h4, h5], { + dashArray: '5, 5' + }); + group.addLayer(line); + polygon.bindPopup('I am a polygon'); map.addLayer(group); diff --git a/src/layer/vector/Canvas.js b/src/layer/vector/Canvas.js index 935f3df6..f11715cd 100644 --- a/src/layer/vector/Canvas.js +++ b/src/layer/vector/Canvas.js @@ -54,6 +54,7 @@ L.Canvas = L.Renderer.extend({ }, _initPath: function (layer) { + this._updateDashArray(layer); this._layers[L.stamp(layer)] = layer; }, @@ -74,12 +75,14 @@ L.Canvas = L.Renderer.extend({ }, _updateStyle: function (layer) { + this._updateDashArray(); + this._requestRedraw(layer); + }, + _updateDashArray: function (layer) { if (layer.options.dashArray) { layer.options._dashArray = layer.options.dashArray.split(',').map(Number); } - - this._requestRedraw(layer); }, _requestRedraw: function (layer) { @@ -138,7 +141,9 @@ L.Canvas = L.Renderer.extend({ ctx.beginPath(); - ctx.setLineDash(layer.options && layer.options._dashArray || []); + if (ctx.setLineDash) { + ctx.setLineDash(layer.options && layer.options._dashArray || []); + } for (i = 0; i < len; i++) { for (j = 0, len2 = parts[i].length; j < len2; j++) {