ggolikov / leaflet.rain Goto Github PK
View Code? Open in Web Editor NEWWebGL rain animation for Leaflet maps
WebGL rain animation for Leaflet maps
I have more than one instance of L.Rain whose velocity and points are different from each other. I tried using L.layerGroup but it didn't work.
Here is my code. Note that rainSpots is a 3D array which contains arrays of [lat,long].
$.getJSON(precipitationFile, function(dat) {
// leaflet-rain layer
rainPoints = (dat['data']).reduce(function (acc, p) { if (p[2] > 0) { acc.push(p) } return acc; }, []);
console.log(rainPoints);
rainSpots = getRainSpots(rainPoints);
tempLayers = [];
for (i = 0; i < rainSpots.length; i++) {
rainSpot = rainSpots[i].map(function (p) { return [p[0], p[1]]; });
sumRainRate = (rainSpots[i].map(function (p) { return p[2]; })).reduce(function(a, b) { return a + b; });
rainRate = sumRainRate / rainSpots[i].length;
rainOptions = {
angle: 70,
width: 3,
spacing: 5,
length: 10,
interval: 11,
speed: rainRate,
color: '0x00FFFF'
};
temp = L.rain(rainSpots, rainOptions);
tempLayers.push(temp);
}
var rainLayers = new L.layerGroup(tempLayers);
layerControl.addOverlay(rainLayers, "Precipitation");
});
Here is the error message:
"There are too many active WebGL contexts on this page, the oldest context will be lost."
Demo only runs with jquery 3.3.1
I'm trying to use leaflet-rain on my map but I'm getting this error. Does the first line of bundle.js define the require function to solve this issue?
The demo is nice on the website, but it seems it's hard to use on my map. Below is what I have encountered. Hope it can be a test case :)
ERROR TypeError: Failed to execute 'attachShader' on 'WebGLRenderingContext': parameter 2 is not of type 'WebGLShader'.
at NewClass._initShaders (L.Rain.js:196)
at NewClass.onAdd (L.Rain.js:31)
at NewClass._layerAdd (leaflet-src.js:6595)
at NewClass.whenReady (leaflet-src.js:4459)
at NewClass.addLayer (leaflet-src.js:6657)
at NewClass.addTo (L.Rain.js:72)
at HeatmapComponent.percipitationDataHandler (heatmap.component.ts:342)
at SafeSubscriber.schedulerFn [as _next] (core.js:31089)
at SafeSubscriber.__tryOrUnsub (Subscriber.js:185)
at SafeSubscriber.next (Subscriber.js:124)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.