Infernus
Infernus

Reputation: 21

Leaflet Loop Snake function on several polyline routes

I currently have two routes, both I stored in an array. I am trying to sequentially animate the routes (polyline) using the following for loop.

var pathmat = [path1, path2];
for (var p = 0; p < 1; p++)
    {
    function snake() {
        pathmat[p].snakeIn();
    }

    pathmat[p].on('snakestart snake snakeend', function(ev){
        console.log(ev.type);
    });
    }

It skips directly to animating path2.

Please help.

NOTE: I am an absolute noob in JS.

Upvotes: 0

Views: 1004

Answers (1)

IvanSanchez
IvanSanchez

Reputation: 19069

You seem to be using my very own Leaflet.SnakeAnim plugin (you should have mentioned this in your question).

The documentation states that you can use snakeIn() on a L.Polyline but also on a L.LayerGroup, and has examples of that. Also look at the source code demo-group.html, which animates several polylines one after another.

Upvotes: 2

Related Questions