A web-based route optimization app that uses Leaflet.js for map visualization and OpenStreetMap for map tiles. The app allows users to:
- Set a start location.
- Add multiple destinations.
- Calculate the optimal route using the OSRM API.
- Interactive Map: Users can click on the map to set the start location and destinations.
- Route Calculation: The app calculates the optimal route between the start location and destinations.
- Custom Markers: Different colored markers for the start location and destinations.
- Responsive Design: Works on both desktop and mobile devices.
- Frontend:
- HTML, CSS, JavaScript
- Leaflet.js for map visualization
- APIs:
- OpenStreetMap for map tiles
- OSRM for route optimization
- Nominatim for geocoding
- OpenCage Geocoder for geocoding (fallback)
- Set the Start Location:
- Enter the start location in the input field or click the "Select on Map" button to choose a location on the map.
- Add Destinations:
- Click the "Add Destination" button to add a new destination.
- Enter the destination in the input field or click the "Select on Map" button to choose a location on the map.
- Calculate the Route:
- Click the "Calculate Route" button to calculate the optimal route.
- The app will display the route on the map and show the estimated distance and time.
To run this project locally, follow these steps:
-
Clone the repository:
git clone https://github.com/your-username/route-optimization-app.git
-
Navigate to the project directory:
cd route-optimization-app -
Open
index.htmlin your browser: Simply open theindex.htmlfile in your preferred browser.
This app uses the following APIs:
- OpenCage Geocoder: Requires an API key. You can get a free API key from OpenCage.
- OSRM: No API key required.
To use your own OpenCage API key, replace the apiKey variable in js/app.js with your API key:
const apiKey = 'YOUR_OPENCAGE_API_KEY';Contributions are welcome! If you'd like to contribute, please follow these steps:
- Fork the repository.
- Create a new branch:
git checkout -b feature/YourFeatureName
- Commit your changes:
git commit -m "Add some feature" - Push to the branch:
git push origin feature/YourFeatureName
- Open a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.
- Leaflet.js for the mapping library.
- OpenStreetMap for providing free map tiles.
- OSRM for the route optimization API.
- OpenCage for the geocoding API.


