Parameters
Success Callback
Error Codes
Default error code is1900. On Google Maps, the response includes status and errorMessage fields corresponding to the Google Maps DirectionsStatus.
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Calculate a route between two points.
| Property | Type | Required | Description |
|---|---|---|---|
| searchType | String | No | Mode of transportation: walk, bus, drive, ride. Default is walk |
| startLat | Number | Yes | Start latitude |
| startLng | Number | Yes | Start longitude |
| endLat | Number | Yes | End latitude |
| endLng | Number | Yes | End longitude |
| throughPoints | Array | No | A set of points along the route |
| mode | Number | No | Different modes of the route. Only supported for driving and public transit modes |
| city | String | Yes | The city of the route. Required in public transit mode |
| destinationCity | String | Yes | The destination city where the route ends. Required in cross-city public transit mode |
| gAPIKey | String | No | The API key required to call this API (Google Maps only) |
| success | Function | No | Callback with route |
| fail | Function | No | Callback on failure |
| complete | Function | No | Callback that always executes |
| Property | Type | Description |
|---|---|---|
| success | Boolean | Whether the API call is successful |
| distance | Number | The distance between the starting point and the endpoint |
| duration | Number | The length of time spent according to the planned route, in seconds |
1900. On Google Maps, the response includes status and errorMessage fields corresponding to the Google Maps DirectionsStatus.
my.calculateRoute({
searchType: 'drive',
startLat: 40.7128,
startLng: -74.0060,
endLat: 40.7580,
endLng: -73.9855,
success: (res) => {
console.log('Distance:', res.distance);
console.log('Duration:', res.duration);
}
});