HERE Android SDK Developer's Guide

Transit Routing

Transit Routes are routes calculated by using CoreRouter with the the RouteOptions transport mode set to PUBLIC_TRANSPORT. With the transit routing feature, you can calculate transit routes by using known online timetable information.

Note:
  • RouteOptions.TransportMode.PUBLIC_TRANSPORT is no longer deprecated as of HERE SDK v3.4.
  • To use this feature, your application must include the Gson library (release 2.2.4 or a compatible version) on its class path.

Before displaying transit routing, you should set the map scheme to include transit so that the MapRoute shows the color of the transit lines.

// sets the map scheme to include transit.
map.setMapScheme(Map.Scheme.NORMAL_DAY_TRANSIT);

The following is an example of a transit route using CoreRouter:

  ...
  CoreRouter router = new CoreRouter();

  // Select routing options
  RoutePlan routePlan = new RoutePlan();

  RouteOptions routeOptions = new RouteOptions();
  routeOptions.setTransportMode(RouteOptions.TransportMode.PUBLIC_TRANSPORT);
  routeOptions.setRouteType(RouteOptions.Type.FASTEST);
  routePlan.setRouteOptions(routeOptions);

  // Select Waypoints for your routes
  routePlan.addWaypoint(new RouteWaypoint(new GeoCoordinate(49.1966286, -123.0053635)));
  routePlan.addWaypoint(new RouteWaypoint(new GeoCoordinate(49.1947289, -123.1762924)));
  router.calculateRoute(routePlan, new RouterListener());

...

private final class RouterListener implements CoreRouter.Listener {

  // Method defined in Listener
  public void onProgress(int percentage) {
    // Display a message indicating calculation progress
  }

  // Method defined in Listener
  public void onCalculateRouteFinished(List<RouteResult> routeResult, RoutingError error) {
    // If the route was calculated successfully
    if (error == RoutingError.NONE) {
      // Render the route on the map
      mapRoute = new MapRoute(routeResult.get(0).getRoute());
      map.addMapObject(mapRoute);

      // Get the bounding box containing the route and zoom in (no animation)
      GeoBoundingBox gbb = routeResult.get(0).getRoute().getBoundingBox();
      map.zoomTo(gbb, Map.Animation.NONE, Map.MOVE_PRESERVE_ORIENTATION);
    }
    else {
      // Display a message indicating route calculation failure
    }
  }
}
Figure 1. Transit Route

The TransitRouteElement Class

Transit route elements, which are route element objects specific to public transit, can be retrieved from the getTransitElement() method in the RouteElement class.

You cannot use this account to purchase a commercial plan on Developer Portal, as it is already associated to plans with different payment methods.

To purchase a commercial plan on Developer Portal, please register for or sign in with a different HERE Account.

Something took longer than expected.

The project should be available soon under your projects page.

Sorry, our services are not available in this region.

Something seems to have gone wrong. Please try again later.

We've detected that your account is set to Australian Dollars (AUD).
Unfortunately, we do not offer checkouts in AUD anymore.
You can continue using your current plan as normal, but to subscribe to one of our new plans,
please register for a new HERE account or contact us for billing questions on selfservesupport@here.com.