This Python script calculates the best route between multiple destinations, optionally starting from a specified origin or using the user's current location. It leverages the Google Maps Directions API to provide detailed directions and estimated travel times, while avoiding highways to potentially bypass restricted roads.
- Calculate optimized routes between multiple destinations.
- Use a specified starting location or automatically detect the current location.
- Display step-by-step directions and estimated travel times.
- Provide alternative routes for manual selection.
- Avoid highways to reduce the likelihood of using restricted roads.
- Python 3.x
- Google Maps API key
- Internet connection
-
Clone the Repository
Clone this repository to your local machine using:
git clone https://github.com/aram-ap/PythonRoutePlanner.git
-
Install Dependencies
Navigate to the project directory and install the required Python packages:
cd PythonRoutePlanner pip install -r requirements.txt
Ensure
requirements.txt
contains:requests python-dotenv argparse
-
Set Up Environment Variables
Create a
.env
file in the project directory and add your Google Maps API key:GOOGLE_MAPS_API_KEY=your_actual_google_maps_api_key
Run the script with the following command:
python run.py [--origin "Starting Address"]
--origin "Starting Address"
: (Optional) Specify the starting location address. If not provided, the script will attempt to use the current location.
python run.py --origin "1234 Elm St, Springfield"
Or, to use the current location:
python run.py
When prompted, enter your destinations as a comma-separated list:
Enter your destinations separated by commas: 26455 Someplace Rd City CA, 22613 Heebee Jeebee Dr Bollywood CA, 31 Spooner Street Quahog Rhode Island
The script will display the best route with detailed directions and estimated travel times. It will also provide alternative routes for manual selection.
- Ensure you have a valid Google Maps API key with access to the Directions API.
- Be aware of the API usage limits to avoid additional charges.
- The script attempts to avoid highways, which may help in bypassing restricted roads, but it cannot guarantee avoidance of all restricted areas.