Skip to content

Support dashed lines #165

@JasonSanford

Description

@JasonSanford

I wanted my lines to be dashed in a Leaflet map I've been working on. This was very easy to implement if the client supports SVG. I added this code at line 86 of Path.SVG.js:

if (this.options.dasharray) {
    this._path.setAttribute('stroke-dasharray', this.options.dasharray);
}

This lets you set the "stroke-dasharray" attribute by changing a simple option to the Path object:

e.layer.setStyle({
    dasharray: "8,6"
});

The product is a pretty nice looking dashed line:

Dashed Lines

This obviously only works with SVG, but I wonder how much work it would be to implement in Canvas. There are some folks who have had some luck doing this.

Any thoughts, opinions?

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions