Get route information

Follow this guide to set up your app to retrieve times, distances, and route legs for the current route.


To get information about the current route, get the appropriate property from the navigator instance:

See the code

Getting time to the next destination

To get the time to the next destination, call timeToNextDestination(). This returns an NSTimeInterval value. The following example shows logging the time to the next destination:


if let navigator = mapView.navigator {
  let time = navigator.timeToNextDestination
  let minutes = floor(time/60)
  let seconds = round(time - minutes * 60)
  NSLog("Time to next destination: %.0f:%.0f", minutes, seconds)


NSTimeInterval time = _mapView.navigator.timeToNextDestination;
int minutes = floor(time/60);
int seconds = round(time - minutes * 60);
NSLog(@"%@", [NSString stringWithFormat:@"Time to next destination: %i:%i.", minutes, seconds]);

Getting distance to the next destination

To get the distance to the next destination, call distanceToNextDestination(). This returns a CLLocationDistance value. Units are specified in meters.


if let navigator = mapView.navigator {
  let distance = navigator.distanceToNextDestination
  let miles = distance * 0.00062137
  NSLog("Distance to next destination: %.2f miles.", miles)


CLLocationDistance distance = _mapView.navigator.distanceToNextDestination;
double miles = distance * 0.00062137;
NSLog(@"%@", [NSString stringWithFormat:@"Distance to next destination: %.2f.", miles]);

Getting traffic conditions to the next destination

To get a value indicating the flow of traffic to the next destination, call delayCategoryToNextDestination. This parameter returns GMSNavigationDelayCategory. The following example shows evaluating the result and logging a traffic message:


if let navigator = mapView.navigator {
  // insert sample for evaluating traffic value
  let delay = navigator.delayCategoryToNextDestination
  let traffic = "unavailable"
  switch delay {
    case .noData:
      traffic = "unavailable"
    case .heavy:
      traffic = "heavy"
    case .medium:
      traffic = "moderate"
    case .light:
      traffic = "light"
      traffic = "unavailable"
  print("Traffic is \(traffic).")


GMSNavigationDelayCategory delay = mapView.navigator.delayCategoryToNextDestination;
NSString *traffic = @"";

switch (delayCategory) {
    case GMSNavigationDelayCategoryNoData:
      traffic = @"No Data";
    case GMSNavigationDelayCategoryHeavy:
      traffic = @"Heavy";
    case GMSNavigationDelayCategoryMedium:
      traffic = @"Medium";
    case GMSNavigationDelayCategoryLight:
      traffic = @"Light";
      NSLog(@"Invalid delay category: %zd", delayCategory);

NSLog(@"%@", [NSString stringWithFormat:@"Traffic is %@.", traffic]);

Getting information about the current leg

To get information about the current route leg, call currentRouteLeg. This returns a GMSRouteLeg instance, from which you can get:

  • The destination for the leg.
  • The final coordinate in the leg.
  • The path containing the coordinates which make up the route leg.

The following example shows logging the title and lat/lng coordinates for the next route leg:


if let navigator = mapView.navigator {
  let currentLeg = navigator.currentRouteLeg
  let nextDestination = currentLeg?.destinationWaypoint?.title
  let lat = currentLeg?.destinationCoordinate.latitude.description
  let lng = currentLeg?.destinationCoordinate.longitude.description
  NSLog(nextDestination! + ", " + lat! + "/" + lng!)


GMSRouteLeg *currentSegment = _mapView.navigator.currentRouteLeg;
NSString *nextDestination = currentSegment.destinationWaypoint.title;
CLLocationDegrees lat = currentSegment.destinationCoordinate.latitude;
CLLocationDegrees lng = currentSegment.destinationCoordinate.longitude;
NSLog(@"%@", [NSString stringWithFormat:@"%@, %f/%f", nextDestination, lat, lng]);

Getting the most recently traveled path

To get the most recently traveled path, call traveledPath. This returns a GMSPath instance which has been simplified to remove redundant points (for example turning consecutive colinear points into a single line segment). This path is empty until guidance is started. The following example shows getting the most recently traveled path:


if let navigator = mapView.navigator {
  let latestPath = navigator.traveledPath
  if latestPath.count() > 0 {
    let begin: CLLocationCoordinate2D = latestPath.coordinate(at: 0)
    let current: CLLocationCoordinate2D = latestPath.coordinate(at: latestPath.count() - 1)
    print("Path from (\(begin.latitude),\(begin.longitude)) to (\(current.latitude),\(current.longitude))")


GMSPath *latestPath = mapView.navigator.traveledPath;
if (latestPath.count > 0) {
  CLLocationCoordinate2D begin = [latestPath coordinateAtIndex:0];
  CLLocationCoordinate2D current = [latestPath coordinateAtIndex:latestPath.count - 1];
  NSLog(@"Path from %f/%f to %f/%f",