I have an application that implements the movement of animation characters along a previously laid route on a city map. Routes, more precisely, the path made manually in the vector editor. All route creation techniques are shown here .
Below is the code that implements this technique and animation:
.container { width:100%; height:100%; } <div class="container"> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1" viewBox="0 0 800 540" > <defs> <path id="walk" d="m343 268 34-10 50-9-33-86 22-14 7-21 8-3 13 18 34-25 47 65 22-19" /> <g id="Man" transform="translate(0,0) scale(1,-1)"> <path fill="none"> <animate attributeName="d" begin="0.1s" dur="0.3s" repeatCount="indefinite" values="M-3,0 0,10 3,0 M0,10 0,16 l 4,-5 M0,16 l-4,-5 M0,16 c4,4 -4,4 0,0; M 0,0 0,10 0,0 M0,10 0,16 l 0,-5 M0,16 l 0,-5 M0,16 c4,4 -4,4 0,0; M-3,0 0,10 3,0 M0,10 0,16 l 4,-5 M0,16 l-4,-5 M0,16 c4,4 -4,4 0,0"/> </path> </g> </defs> <image xlink:href="https://i.stack.imgur.com/XPdWW.png" width="100%" height="100%" /> <path id="train" stroke-dasharray="312" stroke-dashoffset="312" stroke-width="2" d="M443 534 426 477 415 435 397 391 375 347 350 304 334 277 317 251" style="fill:none;stroke:violet;"/> <text font-size="28" font-family="Times New Roman" fill="#517DA6" > <textPath id="result" xlink:href="#train"> <tspan dx="0" > 🚂 </tspan> <tspan dx="-12"> - </tspan> <tspan dx="-15"> 🚃</tspan> <tspan dx="-12"> -</tspan> <tspan dx="-15"> 🚃 </tspan> <tspan dx="-12"> - </tspan> <tspan dx="-15"> 🚃</tspan> <tspan dx="-12"> -</tspan> <tspan dx="-15"> 🚃 </tspan> <tspan dx="-12"> - </tspan> <tspan dx="-15"> 🚃</tspan> <tspan dx="-12"> -</tspan> <tspan dx="-15" > 🚂 </tspan> <animate id="anTrain" begin="0s;an5.end" dur="12s" repeatCount="1" attributeName="startOffset" values="-60%;45%;45%;-60%" fill="freeze"/> </textPath> </text> <path id="walk" stroke-dasharray="409" stroke-dashoffset="409" stroke-width="3" d="m343 268 34-10 50-9-33-86 22-14 7-21 8-3 13 18 34-25 47 65 22-19" style="fill:none;stroke:#B34EE9"> <animate id="anPathWalk" attributeName="stroke-dashoffset" begin="anTrain.end-7.5s" dur="2s" values="409;0" fill="freeze" /> </path> <use xlink:href="#Man" transform="translate(0,0) scale(1.2)" style="stroke:blue; fill:black;"> <animateMotion id="an2" begin="anPathWalk.end" dur="16s" repeatCount="1" > <mpath xlink:href="#walk"/> </animateMotion> </use> <use xlink:href="#Man" transform="translate(0,0) scale(1.2)" style="stroke:crimson;" > <animateMotion id="an3" begin="anPathWalk.end+0.5s" dur="17s" repeatCount="1" > <mpath xlink:href="#walk"/> </animateMotion> </use> <use xlink:href="#Man" transform="translate(0,0) scale(1)" style="stroke:black;"> <animateMotion id="an4" begin="anPathWalk.end+1s" dur="13s" repeatCount="1" > <mpath xlink:href="#walk"/> </animateMotion> </use> <use xlink:href="#Man" transform="translate(0,0) scale(0.8)" style="stroke:red; fill:black;"> <animateMotion id="an5" begin="anPathWalk.end+1.5s" dur="11s" repeatCount="1" > <mpath xlink:href="#walk"/> </animateMotion> </use> <use xlink:href="#Man" transform="translate(0,0) scale(0.8)" style="stroke:black;"> <animateMotion id="an5" begin="anPathWalk.end+1.8s" dur="9.5s" repeatCount="1" > <mpath xlink:href="#walk"/> </animateMotion> </use> </svg> <audio src="https://svg-art.ru/files/Time_Machine.mp3" autoplay="autoplay"></audio> </div> Is it possible to maximally automate the laying of a route from one point of the map to another by creating broken segments of the path clicking the control points of the map, - at the branching of the streets, while changing the direction of movement.
In other words, - the work of the program should repeat the work in the vector editor, when we put the nodal points that are automatically connected by line segments, and at the output we get a ready-made patch formula.
There is a topic in which the laying of routes is implemented, but it requires manually specifying the coordinates of the vertices of broken lines.





