Merge pull request #4364 from Leaflet/fix-canvas-dasharray
Initialize canvas dash on init. Check that canvas supports setLineDash.
This commit is contained in:
commit
ec10c1bb6b
@ -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);
|
||||
|
@ -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();
|
||||
|
||||
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++) {
|
||||
|
Loading…
Reference in New Issue
Block a user