Multi-Location Route Optimizer W Map
Optimizes multi-stop routes to find the most efficient visit order, provides turn-by-turn directions, and generates visual route maps. Supports 2-25 locations with driving, walking, bicycling, and transit modes.
Actions
optimize_route
Finds the most efficient order to visit a set of locations, minimizing total travel time or distance.
Required fields:
locations(array): 2-25 location objects. Each must have eitheraddress(string) ORlatitude/longitude(numbers).
Optional location fields:
name(string): Label for the location (e.g., "Warehouse", "Customer A")service_time_minutes(integer): Time spent at this stop in minutes
Optional fields:
start_location(object): Fixed starting point if different from first location. Object withaddressorlatitude/longitude, and optionalname.end_location(object): Fixed ending point if different from last location. Object withaddressorlatitude/longitude, and optionalname. Ignored whenreturn_to_startis true.return_to_start(boolean): Set totruefor a round trip back to starting location. Default:falsetravel_mode(string):"driving"(default),"walking","bicycling", or"transit"optimize_for(string):"time"(default) or"distance"avoid(array): Features to avoid:"tolls","highways","ferries"departure_time(string): ISO format datetime (e.g.,"2026-01-15T09:00:00") or"now". Traffic-aware routing (driving mode only).include_map(boolean): Generate a visual route map image. Default:falseinclude_directions(boolean): Include turn-by-turn directions. Default:falsemap_width(integer): Map image width in pixels, 1-640. Default: 640map_height(integer): Map image height in pixels, 1-640. Default: 640
Response includes:
optimized_route.locations- Locations in optimized order withtravel_to_next_kmandtravel_to_next_minutesper stopoptimized_route.legs- Per-leg breakdown withfrom,to,distance_km,duration_minutesoptimized_route.total_distance_km- Total route distanceoptimized_route.total_duration_minutes- Total travel time plus service timeoptimized_route.estimated_fuel_cost_usd- Rough fuel cost estimategoogle_maps_url- Clickable Google Maps navigation linkoptimization_stats- Distance/time saved compared to original ordermap_image.signed_url- Route map image URL (wheninclude_map: true). Always present this URL to the user.directions- Turn-by-turn directions (wheninclude_directions: true)
Example - Basic optimization:
{
"action": "optimize_route",
"locations": [
{ "address": "San Francisco, CA" },
{ "address": "San Jose, CA" },
{ "address": "Oakland, CA" }
]
}
Example - Full-featured delivery route:
{
"action": "optimize_route",
"locations": [
{ "address": "123 Main St, San Francisco, CA", "name": "Warehouse", "service_time_minutes": 15 },
{ "address": "456 Oak Ave, San Jose, CA", "name": "Customer A", "service_time_minutes": 30 },
{ "address": "789 Pine St, Oakland, CA", "name": "Customer B", "service_time_minutes": 20 }
],
"start_location": { "address": "100 HQ Blvd, San Francisco, CA", "name": "HQ" },
"return_to_start": true,
"travel_mode": "driving",
"optimize_for": "time",
"avoid": ["tolls"],
"include_map": true,
"include_directions": true
}
Example - Using coordinates:
{
"action": "optimize_route",
"locations": [
{ "latitude": 37.7749, "longitude": -122.4194, "name": "San Francisco" },
{ "latitude": 37.3382, "longitude": -121.8863, "name": "San Jose" },
{ "latitude": 37.8044, "longitude": -122.2712, "name": "Oakland" }
]
}
get_route_details
Gets turn-by-turn directions for locations in the order provided (does not reorder them).
Required fields:
locations(array): 2-25 location objects in the desired visit order
Optional fields:
travel_mode(string):"driving"(default),"walking","bicycling", or"transit"avoid(array): Features to avoid:"tolls","highways","ferries"
Response includes:
directions.legs[]- Per-leg directions with steps, distance, and durationdirections.total_distance- Total distance in kmdirections.total_duration- Total duration in minutesgoogle_maps_url- Clickable Google Maps link
Example:
{
"action": "get_route_details",
"locations": [
{ "address": "Times Square, New York, NY", "name": "Start" },
{ "address": "Central Park, New York, NY", "name": "Stop 1" },
{ "address": "Brooklyn Bridge, New York, NY", "name": "End" }
],
"travel_mode": "walking"
}
create_route_map
Generates a static map image showing the route with labeled markers at each location.
Required fields:
locations(array): 2-25 location objects in the desired order
Optional fields:
travel_mode(string):"driving"(default),"walking","bicycling", or"transit"map_width(integer): Image width in pixels, 1-640. Default: 640map_height(integer): Image height in pixels, 1-640. Default: 640
Response includes:
map_image.signed_url- URL to the generated map image. Always present this URL to the user.map_image.file_id- Storage file IDgoogle_maps_url- Clickable Google Maps link
Example:
{
"action": "create_route_map",
"locations": [
{ "address": "Los Angeles, CA", "name": "LA" },
{ "address": "Las Vegas, NV", "name": "Vegas" },
{ "address": "Phoenix, AZ", "name": "Phoenix" }
],
"map_width": 640,
"map_height": 400
}
Important Notes
- Each location must have either an
addressOR bothlatitudeandlongitude. - You can mix address-based and coordinate-based locations in the same request.
- The
locationsarray must contain between 2 and 25 locations. - When
return_to_startistrue, the route ends back at the starting point;end_locationis ignored. - Map images expire after 7 days. Always display the
signed_urlto the user when a map is generated. - The
google_maps_urlin every response opens the route in Google Maps for interactive navigation. - Optimization uses a nearest-neighbor algorithm; results are very good for typical route sizes but may not be globally optimal for very large sets.
- Set
departure_timeto"now"or an ISO datetime to factor in traffic conditions (driving mode only).







