Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 3 down vote accepted

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.

share|improve this answer
I'm beginner with Java, so I'm not sure how to use this coding. My polyline coding is this: var firstpolyline = new L.Polyline(pointList, { color: 'yellow', weight: 7, opacity: 0.8, smoothFactor: 3 }); map.addLayer(firstpolyline); – againstflow Jul 20 '12 at 10:25

You can use Raphael plugin for Leaflet. This enables you to use SVG animations from Raphael framework.

There is an example on using animated lines from point to point using Bezier lines on link above. You can look in the plugin code and make tweaks to functionality provided or add your own by using Raphael features.

You will need Raphael framework as well:

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.