Get Route Distance
Calculates the driving distance between two geographic coordinates using Google Maps Directions API.
Common Properties
- Name - The custom name of the node.
- Color - The custom color of the node.
- Delay Before (sec) - Waits in seconds before executing the node.
- Delay After (sec) - Waits in seconds after executing node.
- Continue On Error - Automation will continue regardless of any error. The default value is false.
info
If the ContinueOnError property is true, no error is caught when the project is executed, even if a Catch node is used.
Inputs
- Coordinate 1 - Starting geographic coordinate in "latitude,longitude" format (e.g., "41.0082,28.9784").
- Coordinate 2 - Ending geographic coordinate in "latitude,longitude" format (e.g., "40.7128,74.0060").
Options
- Credentials - Google Maps API key credential used to authenticate with the service.
Output
- Distance - The driving route distance between the two coordinates in kilometers.
How It Works
The Get Route Distance node calculates the actual driving distance between two geographic coordinates using Google Maps Directions API. When executed, the node:
- Validates both coordinate inputs
- Parses the latitude and longitude values from each coordinate string
- Retrieves the Google Maps API key from credentials
- Creates a Directions request with the provided coordinates
- Sends the request to Google Maps Directions API
- Calculates the total route distance by summing the distance of all route legs
- Returns the distance in kilometers
Requirements
- A valid Google Maps API key with Directions API enabled
- Two valid geographic coordinates in "latitude,longitude" format
Error Handling
The node will return specific errors in the following cases:
- Empty or invalid Coordinate 1 input
- Empty or invalid Coordinate 2 input
- Invalid or missing Google Maps API credentials
- Incorrect coordinate format (missing comma or invalid numbers)
- Non-numeric latitude or longitude values
- Google Maps API service errors
- Network connectivity issues
- No route found between the coordinates
Usage Notes
- Coordinates should be provided in decimal degrees format
- The distance represents actual driving distance (not straight-line)
- The result is returned in kilometers
- For coordinate formatting, use a comma without spaces (e.g., "41.0082,28.9784")
- This calculation requires an internet connection to access Google Maps API
- The API key must have Directions API permissions enabled
- If no route is found between coordinates, an error will be returned
- The node accounts for one-way streets, road closures, and traffic restrictions