Home > @magiclane/maps-sdk > RoutingService > calculateRoute
RoutingService.calculateRoute() method
Calculate a route between the specified waypoints.
Signature:
static calculateRoute(waypoints: Landmark[], routePreferences: RoutePreferences, onCompleteCallback: (err: GemError, routes: Route[]) => void): TaskHandler | null;Parameters
|
Parameter |
Type |
Description |
|---|---|---|
|
waypoints |
Landmark[] |
The list of waypoints for the route |
|
routePreferences |
The preferences for the route calculation | |
|
onCompleteCallback |
(err: GemError, routes: Route[]) => void |
Will be invoked when the search operation is completed, providing the search results and an error code. - Will be called with GemError.success error and non-empty routes upon success. - Will be called with GemError.notSupported if the provided routing preferences contain an unsupported configuration - Will be called with GemError.invalidInput if the calculation input contains invalid data, e.g. waypoints.length < 1 < 2 for path result or waypoints.length < 1 for range result type - Will be called with GemError.cancel if the route calculation was canceled by the user - Will be called with GemError.waypointAccess if a route couldn't be found using the provided routing preferences - Will be called with GemError.connectionRequired if the routing preferences RoutePreferences.allowOnlineCalculation = false and the calculation cannot be done on client side due to missing necessary data - Will be called with GemError.expired if the calculation cannot be done on client side due to missing necessary data and the client world map data version is no longer supported by the online routing service - Will be called with GemError.routeTooLong if the routing was executed on the online service and the operation took too much time to complete (usually more than 1 min, depending on the server overload state) - Will be called with GemError.invalidated if the offline map data changed (offline map downloaded, erased, updated) during the calculation - Will be called with GemError.noMemory if the routing engine couldn't allocate the necessary memory for the calculation |
Returns:
TaskHandler | null
The TaskHandler associated with the route calculation if it can be started otherwise null.
Exceptions
An exception if it fails.