HERE iOS SDK Developer's Guide

Next Nearby Departures

You can use the HERE SDK to query for the next transit departures for a particular station. Next nearby departure information is based on the timetable information provided by transit agencies, and it includes all types and times of departures from one station at a given time.

Figure 1. Station Departures

To query for the departures, create a request by using the station ID and location parameters and add a completion block, or simply an NMAUrbanMobilityStation object. The returned completion block contains a list of NMAUrbanMobilityDeparture objects that is sorted by the departure times.

// Departures manager singleton
NMAUrbanMobilityRequestManager *departuresManager =
  [NMAUrbanMobilityRequestManager sharedDeparturesManager];

// Chicago, Millenium Park
NMAGeoCoordinates *loc =
  [NMAGeoCoordinates geoCoordinatesWithLatitude:41.882736 longitude:-87.622004];

// Search completion block
void (^completeQuery) (NSArray *, NSError *) =
  ^(NSArray *departures, NSError *error) {
  if (error) {
    // Handle error
    switch (error.code) {
      case NMAUrbanMobilityErrorNotFound:
        // No departures were found
        break;
      default:
        // Handle other errors
        break;
    }
  } else {
    for (NMAUrbanMobilityDeparture *departure in departures) {
      // Handle departure
    }
  }
};

NMAUrbanMobilityDepartureBoardRequest *request =
  [departuresManager createDepartureBoardRequestWithStationId:@"000000001" location:loc];

// Query was triggered successfully
BOOL success;

// Start asynchronous departures query
success = [request startWithCompletionBlock:completeQuery];

All Next Departures

To query for departure information of stations in a given area, create a request by using the location parameter and add a completion block. The returned completion block contains a list of NMAUrbanMobilityStationWithDepartureBoard and NMAUrbanMobilityLine objects that contain departure information, which are sorted by the departure times. NMAUrbanMobilityStationWithDepartureBoard is a child implementation of the NMAUrbanMobilityStation class.

// Departures manager singleton
NMAUrbanMobilityRequestManager *departuresManager =
  [NMAUrbanMobilityRequestManager sharedDeparturesManager];

// Chicago, Millenium Park
NMAGeoCoordinates *loc =
  [NMAGeoCoordinates geoCoordinatesWithLatitude:41.882736 longitude:-87.622004];

// Search completion block
void (^completeQuery) (NSArray *, NSArray *, NSError *) =
  ^(NSArray *stations, NSArray *lines, NSError *error) {
  if (error) {
    // Handle error
    switch (error.code) {
      case NMAUrbanMobilityErrorNotFound:
        // No departures were found
        break;
      default:
        // Handle other errors
        break;
    }
  } else {
    for (NMAUrbanMobilityStationWithDepartureBoard *station in stations) {
      NMAUrbanMobilityDepartureBoard *departureBoard = station.departureBoard;
      for (NMAUrbanMobilityDeparture *departure in departureBoard.departures) {
        // Handle departure
      }
    }
  }
};

NMAUrbanMobilityDepartureBoardRequest *request =
  [departuresManager createMultiBoardRequestWithLocation:loc];

// Query was triggered successfully
BOOL success;

// You can set other search parameters here before starting the search

// Start asynchronous departures query
success = [request startWithCompletionBlock:completeQuery];

You can also set the radius and the stationIds properties in the NMAUrbanMobilitySearchRequest object to limit the search.

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.