A TypeScript fork of leaflet-velocity-ts, now extended and reorganized to support both Leaflet and MapLibre with a clean separation between core logic and mapping libraries.
This plugin allows for the visualization of velocity fields such as wind or ocean currents in both Leaflet and MapLibre maps. It features a 🌊 wave visualization mode and a modular architecture for easy integration.
-
MapLibre Support:
- Use velocity layers natively in MapLibre maps with a dedicated entry point.
-
Wave Mode & API Extensions:
- Wave-style particle animations and height visualization.
- Additional options for wave display and control panel.
import { MapLibreVelocityLayer } from "ih-velocity-ts/maplibre";
const layer = new MapLibreVelocityLayer({
// ...options (see below)
});import "ih-velocity-ts/leaflet";
const layer = L.velocityLayer({
// ...options (see below)
});{
displayValues: true,
displayOptions: {
velocityType: "Global Wind",
position: "bottomleft",
emptyString: "No data",
angleConvention: "bearingCW",
showCardinal: true,
speedUnit: "m/s",
directionString: "Direction",
speedString: "Speed",
heightString: "Height", // 🌊 Wave-specific
heightUnit: "m" // 🌊 Wave-specific
},
data: data, // see demo/*.json or use a compatible data service
minVelocity: 0,
maxVelocity: 10,
velocityScale: 0.005,
colorScale: [],
opacity: 0.97,
paneName: "overlayPane",
particlelineWidth: 1.9,
// 🌊 WAVE MODE CONFIG
waveMode: true,
wavesParticlesSeparation: 3.5
}When waveMode is enabled:
- Particles animate with wave-like appearance rather than simple motion streaks.
- Wave Height is read from the third data parameter (typically
[u, v, height]) and used to scale the wave particles by size and color. - Control Panel includes height data (if available), displaying wave intensity alongside speed and direction.
| Option | Type | Default | Description |
|---|---|---|---|
waveMode |
boolean |
false |
Enable wave visualization mode. |
wavesParticlesSeparation |
number |
3.5 |
Controls the spacing between particles in wave mode. |
heightString |
string |
"Height" |
Label prefix for wave height in the control. |
heightUnit |
string |
"m" |
Unit of wave height displayed in the control. |
| Method | Params | Description |
|---|---|---|
setData |
{Object} |
Update the layer with new data |
setOptions |
{Object} |
Update the layer with new options |
npm install
npm run watchThis project is a fork of leaflet-velocity-ts, which itself is a fork of leaflet-velocity, originally developed by CSIRO.
- 📦 leaflet-velocity – Original plugin developed under CSIRO license.
- 🧪 leaflet-velocity-ts – TypeScript rewrite with performance and compatibility improvements.
- 🌊 ih-velocity-ts – This fork adds wave representation and MapLibre support with a modular architecture.
ih-velocity-ts is released under the CSIRO License.
Redistribution and use in source and binary forms, with or without modification, are permitted under specific terms. See the full CSIRO License for details.
This fork is open to contributions. Feel free to open an issue or submit a pull request if you'd like to suggest improvements or report bugs.

