Drawing roads on maps

Good evening. Recently I decided with a friend to test the knowledge we have gained from a 6-month education, and so we decided to create a mini-routing program based on OSM as our “finishing” project . We parsed the XML successfully, we inserted the coordinates in a custom-made Java class and with the help of a k-short algorithm we got a viable route (an arraylist of nodes) between two nodes.

Our next step was to display that route on OSM. But despite our 3-days of search on the net, we have not found a complete way to do it. I tried with JS, but have only managed to draw semi-random lines that fail spectacularly when we use real coordinates. This is the 3rd evening I fail to progress, it’s making me feel rather hopeless right now, so I started posting around to see if anyone can offer us some guidelines,links or notes as to how this is done. As for my attempts, I tried Open Layers and it was not good, and I found no way to do what I need in leaflet despite trying many examples. Is there anyone who has any idea?

If you have an array of nodes, you could take their coordinates and convert them into a GPX track, which you can then display using OpenLayers. I think that shouldn’t be too difficult, there is also an example in the wiki:


Thank you dear sir! I was emailed this very answer about half an hour ago, and I already tested it with manual insertion. Works great, we now only have to append the results to the gpx instead of the txt. Half an hour work at worst! Still, thank you, this answer was actually the best and easiest solution!

By the way, we can put [Solved] around the title now!