public interface RouteService

Known subtypesOsrmRouteService

A backend that turns a RouteRequest into road-following Routes.

Codename One ships OsrmRouteService, which needs no API key, and Routing uses it unless you install another. Implement this interface to route through a different provider (Google Directions, Mapbox Directions, GraphHopper, your own server) and install it with Routing.setService(RouteService) – application code that calls Routing keeps working unchanged.

Methods

public abstract String getId()A short identifier for this backend, for example "osrm".
public abstract boolean isAvailable()Whether this service can route right now.
public abstract void findRoutes(RouteRequest request, RouteCallback callback)Routes request and reports the outcome to callback.

Method details

getId

public abstract String getId()
A short identifier for this backend, for example "osrm". Used in log messages and to tell services apart.

isAvailable

public abstract boolean isAvailable()
Whether this service can route right now. A service that needs an API key returns false until one is configured, letting callers fail fast with a clear message instead of a network error.

findRoutes

public abstract void findRoutes(RouteRequest request, RouteCallback callback)

Routes request and reports the outcome to callback.

The call returns immediately; the work happens off the event dispatch thread and the callback is invoked back on it. Implementations must invoke exactly one callback method for every request, including when the request is rejected outright.

callback is required – an asynchronous call with nowhere to report its result is a mistake, not a fire-and-forget mode, so implementations reject a null one with IllegalArgumentException rather than returning quietly and leaving the caller to wonder.