
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
leaflet.pattern
Advanced tools
Provides the ability to use SVG patterns as backgrounds for Leaflet Paths.
Provides the ability to use SVG patterns as backgrounds for Leaflet Paths.
Requires Leaflet 0.7.0 or newer.
You can define a pattern in 2 ways.
In either case the Pattern object needs to be initialized. This can be done as follows.
var pattern = new L.Pattern({options});
Options All custom and pre-defined patterns can make use of the following options.
Pre-Built patterns are just an easier way to use some common patterns. Pre-Built patterns typically have their own special options, but all can use the base options mentioned above.
var stripes = new L.StripePattern({options});
stripes.addTo(map);
Options
Once the pre-built patterns are defined you can use them by adding them as the fill pattern property of any Path in leaflet.
var circle = new L.Circle({LatLng}, {radius}, {
fillPattern: stripes,
fillOpacity: 1.0});
circle.addTo(_map);
To create custom patterns you must first create some shapes to define what the pattern looks like.
Options
All shapes have the following options.
var shape = new L.PatternPath({
d: 'M10 0 L7 20 L25 20 Z',
fill: true
});
Options
var shape = new L.PatternCircle({
x: 12,
y: 12,
radius: 10,
fill: true
});
Options
var shape = new L.PatternRect({
x: 5,
y: 5,
width: 40,
height: 40,
rx: 10,
ry: 10,
fill: true
});
Options
Once the paths are defined you can use them by adding them to a Pattern.
var pattern = new L.Pattern({options});
pattern.addShape(shape);
pattern.addTo(map);
Finally you can now use the pattern in the fill pattern property of any Path in leaflet.
var circle = new L.Circle({LatLng}, {radius}, {
fillPattern: pattern,
fillOpacity: 1.0});
circle.addTo(_map);
FAQs
Provides the ability to use SVG patterns as backgrounds for Leaflet Paths.
The npm package leaflet.pattern receives a total of 2,408 weekly downloads. As such, leaflet.pattern popularity was classified as popular.
We found that leaflet.pattern demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.