HERE Android 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 following code demonstrates how to trigger a station search by location:

GeoCoordinate centerCoordinates = new GeoCoordinate(40.750488, -73.993546);  //somewhere in NY

// listener that will be notified after request is completed
RequestManager.ResponseListener<StationSearchResult> responseListener = new RequestManager.ResponseListener<StationSearchResult>() {

  @Override public void onSuccess(StationSearchResult searchResult) {
    List<Station> foundStations = searchResult.getStations();
    Collection<Transport> transports = searchResult.getTransports();
    for (Station station: foundStations) {
      String stationName = station.getAddress().getName();
      // ...
    }
    // ...
  }

  @Override public void onError(ErrorCode errorCode, String errorMessage) {
    // report error
  }
};

// creating and executing the request
// search stations nearby
StationSearchRequest requestNearby = new RequestManager().createStationSearchRequest(
    centerCoordinates, "", responseListener)
    .setMaximumResults(3)
    .setRadius(1000);
requestNearby.execute();
Figure 2. Station Search by Name

You can also search for public transit stations by providing its name. For example, a user searching for "Penn" 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 stations nearby with given name filter, returning transports information
StationSearchRequest requestName = new RequestManager().createStationSearchRequest(
    centerCoordinates, "Penn", responseListener)
    .setStationNameMatchingMethod(StationSearchRequest.NameMatchingMethod.FUZZY)
    .setRequestStationDetailsEnabled(true);
requestName.execute();

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

Set<String> ids = new HashSet<String>();
ids.add("717010002");
ids.add("717001746");

// search stations by given IDs
StationSearchRequest requestIds = new RequestManager().createStationSearchRequest(
    ids, responseListener);
requestIds.execute();

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.