HERE iOS SDK Developer's Guide

Transit Routing

Transit routes are routes calculated using NMACoreRouter, with NMATransportMode set to NMATransportModePublicTransport in NMARoutingMode. With the transit routing feature, you can calculate transit routes by using known online timetable information.

You can add a variety of restrictions, such as Avoid Boats, by using the transitRoutingOptions property. You can also limit the desired number of transit vehicle changes by using the maximumChanges property.

When a transit route is found, NMACoreRouter returns the calculation result block and route result via the calculateRouteWithStops:routingMode:completionBlock: method. An NMARoute contains one or more maneuvers, represented by the NMAManeuver class. Each of these maneuvers is either a pedestrian or a public transit maneuver. If a maneuver is a public transit maneuver, information specific for transit can be accessed by downcasting the NMAManeuver to NMATransitManeuver. An NMATransitManeuver contains one or more NMATransitRouteElement objects. Each NMATransitRouteElement object contains the departure station, the arrival station and travel time of that transit maneuver.
Note: Transit directions are only available in certain areas of the world.

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

NMACoreRouter* coreRouter = [[NMACoreRouter alloc] init];

NMAGeoCoordinates* geoCoord1 =
  [[NMAGeoCoordinates alloc] initWithLatitude:49.1966286 longitude:-123.0053635];
NMAGeoCoordinates* geoCoord2 =
  [[NMAGeoCoordinates alloc] initWithLatitude:49.1947289 longitude:-123.1762924];

NMAWaypoint* waypoint1 = [[NMAWaypoint alloc] initWithGeoCoordinates:geoCoord1];
NMAWaypoint* waypoint2 = [[NMAWaypoint alloc] initWithGeoCoordinates:geoCoord2];

NSMutableArray* stops = [[NSMutableArray alloc] initWithCapacity:4];
[stops addObject:waypoint1];
[stops addObject:waypoint2];

NMARoutingMode* routingMode = [[NMARoutingMode alloc]
  initWithRoutingType:NMARoutingTypeFastest
  transportMode:NMATransportModePublicTransport
  routingOptions:0];

[coreRouter calculateRouteWithStops:stops routingMode:routingMode
  completionBlock:^(NMARouteResult *routeResult, NMARoutingError error) {

    // If the route was calculated successfully
    if (!error && routeResult && routeResult.routes.count > 0)
    {
      NMARoute* route = [routeResult.routes objectAtIndex:0];
      // Render the route on the map
      NMAMapRoute* mapRoute = [NMAMapRoute mapRouteWithRoute:route];
      [mapView addMapObject:mapRoute];

      // In order to see the entire route, we orientate the map view
      // accordingly
      [mapView setBoundingBox:route.boundingBox
          withAnimation:NMAMapAnimationLinear];
    }
    else if (error)
    {
      // Display a message indicating route calculation failure
    }
  }];

Before displaying transit routes, set the map scheme to include transit so that the NMAMapRoute shows the color of the transit lines. You should also use the setBoundingBox:withAnimation: method to pan and zoom the view to display the entire route.

// sets the map scheme to include transit.
[mapView setMapScheme:NMAMapSchemeNormalDayTransit];
// zoom to display the entire route
[mapView setBoundingBox:route.boundingBox withAnimation:NMAMapAnimationBow];

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.