Skip to content
IndexRequest a UIAboutContact

Route Path Draw on Map

A route drawn across a simple map with a pin travelling along it, a scrub slider and distance and time readouts.

Open alone ↗

AI prompt

PROMPT: PASTE INTO YOUR AI IMAGE OR VIDEO TOOL
Clean flat map illustration of a small neighbourhood with pale blocks, a river and a park, a bold blue route line curving from a green start marker labelled A to a red end pin labelled B, the route partly drawn with a round pin at the current position, small info chip near the pin reading 2.4 km and 9 min, soft grey streets, light theme, flat modern style. Negative: real map labels, logos, clutter, text errors. Reduced motion: static design.

About this pattern

Definition

Animating a route helps people understand a journey: where it starts, where it turns and how long it takes. The line is a single SVG path drawn with stroke-dashoffset, and a pin follows it using getPointAtLength so it stays exactly on the line, even around curves.

When to use it

  • Use one path for the route and set pathLength or read getTotalLength to drive the animation.
  • Place the pin with getPointAtLength(progress * length) and rotate it by sampling a point just ahead.
  • Show start and end markers and update distance and time from the same progress value.
  • Offer a scrub slider so the viewer can control the pace.

What the controls do

  • Play, replay and a Progress slider to scrub.

Motion & timing

  • The trip animates over 5 seconds.
  • Reduced motion: no autoplay; use the slider.

Tips & variations

  • Provide the route description in text for people who cannot see the map.
  • Do not use colour alone; label start and end.

Code of this live preview

HTML
<div class="bx"><svg class="mp" viewBox="0 0 300 130" role="img" aria-label="Route from A to B across a simple map"><rect width="300" height="130" fill="#eef1ec"/><path d="M0 92 C60 80 90 110 150 98 S250 70 300 84 V130 H0Z" fill="#cfe3f2"/><rect x="190" y="14" width="80" height="40" rx="8" fill="#d9ebcf"/><g fill="#fff"><rect x="14" y="14" width="46" height="30" rx="4"/><rect x="70" y="14" width="46" height="30" rx="4"/><rect x="14" y="54" width="46" height="26" rx="4"/><rect x="126" y="14" width="54" height="30" rx="4"/></g><path id="rt" d="M24 64 C60 64 70 50 94 50 S130 62 150 58 S170 30 200 34 S240 60 276 36" fill="none" stroke="#c7d3f6" stroke-width="6" stroke-linecap="round"/><path id="rd" d="M24 64 C60 64 70 50 94 50 S130 62 150 58 S170 30 200 34 S240 60 276 36" fill="none" stroke="#2f6bff" stroke-width="6" stroke-linecap="round" pathLength="1" stroke-dasharray="1" stroke-dashoffset="1"/><circle cx="24" cy="64" r="6" fill="#1f9d55"/><text x="24" y="82" font-size="9" text-anchor="middle" fill="#333" font-family="system-ui">A</text><text x="276" y="28" font-size="9" text-anchor="middle" fill="#333" font-family="system-ui">B</text><circle id="pn" r="7" fill="#fff" stroke="#2f6bff" stroke-width="3"/></svg><label class="rw">Progress <b id="pv">0%</b><input id="ps" type="range" min="0" max="100" value="0"></label><div class="two"><button class="mini" id="pl" type="button">Play</button><p class="out" id="out"></p></div></div>

Related patterns

SVG Line Draw

↗
SVG Line DrawMotion & Transitions

Timeline Playhead Milestones

↗
Timeline Playhead MilestonesExplainers & Series

Process Flow Build

↗
Process Flow BuildExplainers & Series