[Leaflet] Update to support dashed lines and circles

This commit is contained in:
McBen 2016-12-31 07:48:06 +01:00
parent 2bdc063ab7
commit 0f86bfae6a

View File

@ -5103,6 +5103,12 @@ L.Path = (L.Path.SVG && !window.L_PREFER_CANVAS) || !L.Browser.canvas ? L.Path :
_updateStyle: function () {
var options = this.options;
if (options.dashArray) {
var da = typeof(options.dashArray) === "string" ? options.dashArray.split(",").map(function(el,ix,ar) { return parseInt(el); }) : options.dashArray;
this._ctx.setLineDash(da);
} else {
this._ctx.setLineDash([]);
}
if (options.stroke) {
this._ctx.lineWidth = options.weight;
this._ctx.strokeStyle = options.color;
@ -5121,7 +5127,14 @@ L.Path = (L.Path.SVG && !window.L_PREFER_CANVAS) || !L.Browser.canvas ? L.Path :
_drawPath: function () {
var i, j, len, len2, point, drawMethod;
if (this.options.dashArray) {
var da = typeof(this.options.dashArray) === "string" ? this.options.dashArray.split(",").map(function(el,ix,ar) { return parseInt(el); }) : this.options.dashArray;
this._ctx.setLineDash(da);
} else {
this._ctx.setLineDash([]);
}
this._ctx.beginPath();
for (i = 0, len = this._parts.length; i < len; i++) {
@ -5148,6 +5161,12 @@ L.Path = (L.Path.SVG && !window.L_PREFER_CANVAS) || !L.Browser.canvas ? L.Path :
var ctx = this._ctx,
options = this.options;
if (options.dashArray) {
var da = typeof(options.dashArray) === "string" ? options.dashArray.split(",").map(function(el,ix,ar) { return parseInt(el); }) : options.dashArray;
ctx.setLineDash(da);
} else {
ctx.setLineDash([]);
}
this._drawPath();
ctx.save();
this._updateStyle();
@ -6075,6 +6094,12 @@ L.Polygon.include(!L.Path.CANVAS ? {} : {
L.Circle.include(!L.Path.CANVAS ? {} : {
_drawPath: function () {
if (this.options.dashArray) {
var da = typeof(this.options.dashArray) === "string" ? this.options.dashArray.split(",").map(function(el,ix,ar) { return parseInt(el); }) : this.options.dashArray;
this._ctx.setLineDash(da);
} else {
this._ctx.setLineDash([]);
}
var p = this._point;
this._ctx.beginPath();
this._ctx.arc(p.x, p.y, this._radius, 0, Math.PI * 2, false);