It's been almost a year since I learned JavaScript. I have come across a long way since then. I got to learn quite a few things about the language. And I did a few projects with JavaScript but this was my first one! Making a Google Map like web app that can tell the best path to take to get to the destination. I built this with just HTML and the Mapbox library. I could've achieved the same output with python but I would always prefer JS to Python when it comes to building webapp as JS supports client side rendering whereas Python needs a backend hosted in a computer to achieve the same result. Not a cost effective way to put your apps on the web.
So I just used Mapbox's API to setup a map and added Navigation controls with the built in mapboxgl.NavigationControl
function to add origin and destination points. It uses Dijkstra's algorithm to determine the best available path to go from the origin to destination. And a then I added few functions to handle the errors. And Here's how the file rendered like:
To use it, just go to my website and click on anywhere on the map to set the origin and then click again to your desired location where you'd like to travel to. You can also look up places by clicking on "Choose a starting place" or "Choose destination" and start typing the name of your desired location. You can view the codes from my repository on github and I hosted the html file with Github pages which is free! It also doesn't collect any data like Google so you don't even have to worry about privacy.