npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

leaflet-line-pattern

v0.0.3

Published

leaflet-line-pattern is a leaflet plugin that enables more options for how a line should be drawn, such as adding arrowheads or tick marks.

Downloads

14

Readme

leaflet-line-pattern

leaflet-line-pattern is a leaflet plugin that enables more options for how a line should be drawn, such as adding arrowheads or tick marks.

Check out the live demo.

lines drawn with various patterns

Getting Started

Install

npm i leaflet-line-pattern

Import

import SvgPatternRenderer from "leaflet-line-pattern";

Using the renderer

Simply pass the renderer as an option to your Leaflet map.

const map = new L.Map("map", {
  renderer: new SvgPatternRenderer(),
})

Then, include the "pattern" option in your layer style.

{
  color: "red",
  weight: 1,
  pattern: "M0 0L3 5M0 0L-3 5,20,20,T",
}

Pattern definitions

Patterns are defined with a semicolon-separated string of one or more pattern parts. Each part is a comma-separated string of four parameters:

  1. The SVG path commands defining the image to be repeated along the line. The direction of travel of the line is the negative Y direction of the path.
  2. An offset after which to start repeating the pattern part. This can be defined with just a number (pixels) or with a percentage of the line length. Default: 0.
  3. The repetition interval of the pattern part. This can be defined with just a number (pixels) or with a percentage of the line length. Default: 100%.
  4. A "T" or "F" indicating a boolean flag. If any pattern part has "T" here, the underlying line will be drawn. If all parts of a pattern have "F" here, the pattersn will be repeated along the line, but it will not be drawn. Default: "F". Note: does not apply to polygons. The line will be drawn regardless, so it can be filled.

Example

A single tick mark in the middle of the line could be defined by:

"M-3 0 3 0,50%,,T"

  • path: horizontal line of length 6
  • offset: 50%
  • interval: 0
  • line: traced

Note that this will be the middle of the displayed line. If only a portion of the line is in view, Leaflet will clip it, so the tick mark may not be at the geographic middle mark.

Because the pattern path is defined with negative Y as the direction of travel, if a horizontal line is drawn with this pattern, the pattern path will be rotated to be a vertical tick mark.

a horizontal line with a vertical tick mark in the middle