package com.codename1.maps.routing

Road-following routes for the modern maps API.

A Polyline connects the coordinates you hand it with straight segments, which is rarely what a navigation screen wants. This package works out the geometry of the roads between two points so the line on the map traces the drive a user would actually make.

Routing is the entry point and works with no configuration – it routes over OpenStreetMap data through the keyless OsrmRouteService, mirroring how MapView draws the keyless OpenFreeMap basemap:

MapView map = new MapView();
Routing.showRoute(map, origin, destination);

A RouteRequest adds waypoints and a TravelMode; the resulting Route carries the drawable geometry, the total distance and duration, and the RouteLeg/RouteStep breakdown behind a turn-by-turn list.

The default service is backed by OSRM’s public demo server, which is fine for development but has no SLA. Production apps point it at their own instance, or install a different backend entirely by implementing RouteService and passing it to Routing.setService – app code that calls Routing is unaffected either way.

Types

class OsrmRouteServiceThe keyless RouteService Codename One uses by default: routing over the OpenStreetMap road network through the OSRM HTTP API.
class RouteA road-following journey returned by a RouteService: the geometry that traces the actual roads, how long it is, how long it takes, and the legs and turn-by-turn steps that make it up.
interface RouteCallbackReceives the outcome of a routing request.
class RouteLegThe portion of a Route between two consecutive stops.
class RouteRequestDescribes the journey to route: where it starts, where it ends, anything it must pass through on the way, and how the traveller moves.
interface RouteServiceA backend that turns a RouteRequest into road-following Routes.
class RouteStepOne maneuver of a RouteLeg – “turn left onto Elm Street and continue for 300 m” – together with the piece of road geometry it covers.
class RoutingThe entry point for road-following routes.
enum TravelModeHow the traveller moves, which decides the road network and speeds a RouteService routes over.