Stay organized with collections
Save and categorize content based on your preferences.
Solving TSPs with the Google Directions API
Google also provides a way to solve simple TSPs of real-world locations without
downloading OR-Tools. If you have a Google Directions API key, you can solve
TSPs of real-world locations with the
Directions API
, providing the locations in a URL and getting the response back as JSON.
You'll need your own
free Directions API key
for development, or an enterprise key for commercial use.
As an example, here's a URL that can be used to find a short tour of winemaking
regions in South Australia, beginning in Adelaide. If you want to try this from
your browser, replace API_KEY at the end of the URL with your key.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-08-28 UTC."],[[["Google Directions API can be used to solve Traveling Salesperson Problems (TSPs) for real-world locations without needing OR-Tools."],["This requires a Google Directions API key, obtainable for free for development or as an enterprise key for commercial purposes."],["By providing locations within a structured URL, the API returns a JSON response detailing the optimal route and directions."],["The response includes comprehensive information like distances, durations, and step-by-step navigation instructions."]]],["The Google Directions API can solve Traveling Salesperson Problems (TSPs) for real-world locations. Users must obtain a Directions API key. By constructing a URL with locations as waypoints, the API returns a JSON response containing the optimized route. For example, a URL can be created to find a route between winemaking regions in South Australia starting in Adelaide. The returned JSON provides detailed directions for the solution, including distance, duration, and specific steps.\n"]]