
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
mapbox-gl-layer
Advanced tools
A high-performance wind field animation layer for Mapbox GL JS using WebGL2 particle system
A high-performance wind field animation layer for Mapbox GL JS using WebGL2 particle system.
npm install mapbox-gl-layer mapbox-gl
or with yarn:
yarn add mapbox-gl-layer mapbox-gl
or with pnpm:
pnpm add mapbox-gl-layer mapbox-gl
import mapboxgl from 'mapbox-gl';
import { MapboxWindLayer } from 'mapbox-gl-layer';
import type { WindData } from 'mapbox-gl-layer';
mapboxgl.accessToken = 'YOUR_MAPBOX_TOKEN';
const map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/mapbox/dark-v11',
center: [0, 20],
zoom: 2
});
map.on('load', () => {
// Create wind layer
const windLayer = new MapboxWindLayer('wind', {
particleCount: 5000,
particleAge: 100,
speedFactor: 0.5,
fadeOpacity: 0.94,
colorRamp: [
'#3288bd', '#66c2a5', '#abdda4', '#e6f598',
'#fee08b', '#fdae61', '#f46d43', '#d53e4f'
]
});
// Set wind data
const windData: WindData = {
uv: Float32Array, // [u0, v0, u1, v1, ...]
width: 100,
height: 50,
minU: -10,
maxU: 10,
minV: -10,
maxV: 10,
bounds: {
minLon: -180,
minLat: -85,
maxLon: 180,
maxLat: 85
}
};
windLayer.setData(windData);
// Add to map
map.addLayer(windLayer);
});
MapboxWindLayernew MapboxWindLayer(id: string, options?: WindLayerOptions)
particleCount (number): Number of particles (default: auto-detected based on device)particleAge (number): Particle lifetime in frames (default: auto-detected)speedFactor (number): Speed multiplier (default: 0.5)fadeOpacity (number): Trail fade opacity (default: auto-detected)colorRamp (string[]): Color gradient array (default: blue to red)wrapX (boolean): Enable horizontal wrapping (default: auto-detected)pauseOnInteraction (boolean): Pause rendering during map interactions (default: true)interactionDelay (number): Delay before resuming after interaction (default: 150ms)devicePerformance ('high' | 'medium' | 'low' | 'auto'): Device performance level (default: 'auto')maxTextureSize (number): Maximum texture size for mobile devices (default: 4096)enableAdaptiveQuality (boolean): Enable adaptive quality based on device (default: true)setData(data: WindData): Update wind field datagetPerformanceInfo(): Get device performance information
{
detected: 'high' | 'medium' | 'low',
isMobile: boolean,
particleCount: number,
renderScale: number
}
WindDatainterface WindData {
uv: Float32Array; // UV data [u0, v0, u1, v1, ...]
width: number; // Data width
height: number; // Data height
minU: number; // Min U component
maxU: number; // Max U component
minV: number; // Min V component
maxV: number; // Max V component
alpha?: Float32Array; // Optional alpha channel
bounds?: { // Geographic bounds
minLon: number;
minLat: number;
maxLon: number;
maxLat: number;
};
}
ColorLayerFor displaying scalar rasters (e.g., temperature/precipitation) with a custom color ramp. Uses a WebGL2 custom layer with world wrapping and optional mask support.
import { ColorLayer } from 'mapbox-gl-layer';
const layer = new ColorLayer('color-layer', {
image: dataImage, // HTMLImageElement | ImageBitmap
colorImage: colorbarImage, // HTMLImageElement | ImageBitmap
maskImage: maskImage, // optional mask (alpha) image
meta: {
min_lon: -180,
max_lon: 180,
min_lat: -85,
max_lat: 85,
range: [0, 100], // data value range in the image
},
colorRange: [10, 80], // optional display range; defaults to meta.range
opacity: 0.85, // optional global opacity (0-1), default 1
});
map.addLayer(layer);
setImage(image): update the raster texture.setMaskImage(maskImage | null): update or clear the mask texture.setColorbarImage(colorImage): update the color ramp texture.setMeta(meta): update geographic bounds and data range; invalidates cached world copies.setColorRange(range | null): override or reset the display range used for ramp mapping.setOpacity(opacity): set global opacity (0-1).The library automatically detects device performance and adjusts rendering parameters:
const windLayer = new MapboxWindLayer('wind', {
devicePerformance: 'auto', // Auto-detect (default)
enableAdaptiveQuality: true // Enable adaptive quality (default)
});
// Get performance info
const info = windLayer.getPerformanceInfo();
console.log('Device:', info.detected); // 'high' | 'medium' | 'low'
console.log('Mobile:', info.isMobile); // true | false
console.log('Particles:', info.particleCount); // Actual particle count
console.log('Scale:', info.renderScale); // Render resolution scale
| Level | Particles | Render Scale | Wrap X | Use Case |
|---|---|---|---|---|
| High | 5000 | 100% | ✅ | Desktop, high-end mobile |
| Medium | 3500 | 75% | ✅ | Mid-range mobile |
| Low | 2000 | 50% | ❌ | Low-end mobile |
const windLayer = new MapboxWindLayer('wind', {
devicePerformance: 'low', // Force low performance mode
maxTextureSize: 2048 // Limit texture size
});
# Install dependencies
npm install
# Start dev server
npm run dev
# Build library
npm run build
| Browser | Minimum Version | Notes |
|---|---|---|
| Chrome | 56+ | Full support |
| Firefox | 51+ | Full support |
| Safari | 15+ | Full support |
| Edge | 79+ | Full support |
Requirements:
EXT_color_buffer_float extensionPerformance is automatically optimized based on device capabilities.
Contributions are welcome! Please feel free to submit a Pull Request.
git checkout -b feature/AmazingFeature)git commit -m 'Add some AmazingFeature')git push origin feature/AmazingFeature)See CHANGELOG.md for a list of changes.
MIT © [Your Name]
See LICENSE for more information.
FAQs
A high-performance wind field animation layer for Mapbox GL JS using WebGL2 particle system
The npm package mapbox-gl-layer receives a total of 4 weekly downloads. As such, mapbox-gl-layer popularity was classified as not popular.
We found that mapbox-gl-layer demonstrated a healthy version release cadence and project activity because the last version was released less than 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.