HERE iOS SDK Developer's Guide

Transit Station Search

Figure 1. Station Search by Coordinates

The Transit Stations Search feature allows users to discover transit stations by searching for stations around a specified location. For example, your application can look for the nearest subway station by retrieving all subway stations at the current location with the specified radius.

The follow code demonstrates how to trigger a station search by location:

// request manager singleton
NMAUrbanMobilityRequestManager *requestManager =
  [NMAUrbanMobilityRequestManager sharedRequestManager];

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

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

NMAUrbanMobilityStationSearchRequest *request =
  [requestManager createStationSearchRequestWithLocation:location];

// Search was triggered successfully
BOOL success;

// Start asynchronous stations search
success = [request startWithCompletionBlock:completeSearch];
Figure 2. Station Search by Name

You can also search for public transit stations by providing its name. For example, a user searching for "Alexanderplatz" retrieves all stations that match that name. This search is location-aware, so results are sorted by proximity to the current location.

The following code demonstrates how to perform a station search and filter by the specified name:

// ...
// Search was triggered successfully
BOOL success;
request.searchRange = 1000;
request.stationName = @"Alexanderplatz";

// Start asynchronous stations search with location and optional name
success = [request startWithCompletionBlock:completeSearch];

You can also retrieve a station directly by specifying the stationIds while creating the NMAUrbanMobilityStationSearchRequest, as demonstrated in the following:

// List of station ids to search for
NSArray *stationIds = @[@"000000001", @"000000002"];

//create search request
NMAUrbanMobilityStationSearchRequest *request =
  [requestManager createStationSearchRequestWithIds:stationIds];

// Search was triggered successfully
BOOL success;

// Start asynchronous station search
success = [request startWithCompletionBlock:completeSearch];

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.