[GIS] Animated lines and line styles in Javascript

javascriptleaflet

I'm using Leaflet library and Mapbox. I need to create animated line from one city to another, slow motion "travelling" from one point to another point. Is that possible in javascript and how? I can add any tools if it's necessary.

Also, I would need some zig zag line, not just straight line, do you have some advices regards to that? Is there some library or something similar where we can choose line styles maybe?

Thank you.

Best Answer

you can use this javascipt for adding small piece of line with time delay to complete the entire line.

time = 0;
    for (var i = 0; i < 5; i++) {
        time += 1000;
        setTimeout(function(j) {
            return function() {
                console.log("var is now", j);
            }
        }(i), time);
    };

beside this you can check out here about animation examples for some inspiration.

i hope it helps you.