Navigation SDK is currently available only to select customers. Contact sales to learn more.

Navigation-only data feed

Stay organized with collections Save and categorize content based on your preferences.

A navigation-only data feed provides navigation-only information to devices not designed for map-based navigation guidance. It provides upcoming maneuvers with icons (left, right, U-turn), turns numbers in roundabouts, road names, and estimated distances and time to the next navigation step or final destination.

You can use this feed to create experiences where the full Navigation SDK UI is not appropriate, such as for small screen displays or devices where a full Android stack is not available. For example, you might use this for two-wheeled vehicle riders, where you can project navigation-only guidance to help them reach their destinations faster and more confidently with minimal distractions.

About event handling

To use navigation-only data, you have to implement an event listener for the didChangeNavInfo event. Within the event listener, access trip and step information to provide turn by turn navigation to your users.

To implement event handlers, the view controller of the map must implement the GMSNavigatorListener protocol. For detailed information on handling events in the Navigation SDK for iOS, see Listening to Navigation Events.

Handling the didChangeNavInfo event

Create a listener for the didChangeNavInfo event to add TurnByTurn support to you app. In the event listener, use the following classes and enums to control TurnByTurn navigation:

Shown below are example event listeners for the didChangeNavInfo event:

Objective-C

  // ViewController.h
  @interface SomeViewController () <GMSNavigatorListener>

  @end

  // ViewController.m
  @implementation SomeViewController
  // Some initialization code.
  ... {
    ...
    [_mapView.navigator addListener:self];
    ...
  }

  #pragma mark GMSNavigatorListener
  - (void)navigator:(GMSNavigator *)navigator didUpdateNavInfo:(GMSNavigationNavInfo *)navInfo {
    // Get the current step information
    if (navInfo.navState == GMSNavigationNavStateEnroute) {
      GMSNavigationStepInfo *currentStep = navInfo.currentStep;
      if (currentStep) {
        ...
        roadNameLabel.text = currentStep.simpleRoadName;
        ...
      }
    }
    ...
  }

Swift

  // ViewController.swift
  class SomeViewController: UIViewController {
    ...
    mapView.navigator?.add(self);
    ...
  }

  extension SomeViewController: GMSNavigatorListener {
    func navigator(_ navigator: GMSNavigator,
                   didUpdateNavInfo navInfo: GMSNavigationNavInfo) {

      // Get the current step information
      if navInfo.navState == .enroute {
        if let currentStep = navInfo.currentStep {
          ...
          roadNameLabel.text = currentStep.simpleRoadName
          ...
        }
      }
    }
  }

Essential navigation display elements

The primary fields for each navigation step are the full road name, maneuver icon, and distance to the next step, which are available in GMSNavigationStepInfo.

For the overall trip, you may want to display the remaining time and distance to the destination, both of which are available in GMSNavigationNavInfo. The following image shows an example of these essential navigation elements.

A mobile screen that displays an upcoming left turn in 100 feet onto
W Ahwanee Ave. At the bottom of the screen, time remaining to destination
is 46 minutes, and distance remaininig is 39 miles.

Use navState property of GMSNavigationNavInfo to get the current state of navigation, which is one of the following:

  • Enroute - The GMSNavigationNavStateEnroute state means that guided navigation is currently active and the user is on the provided route. Information about the current upcoming maneuver step is available.

  • Rerouting - GMSNavigationNavStateRerouting means that navigation is in progress, but the navigator is looking for a new route. The upcoming maneuver step is not available, because there's no new route yet.

  • Stopped - GMSNavigationNavStateStopped means navigation has ended. For example, navigation stops when the user exits navigation in the app. In the sample app, a GMSNavigationNavStateStopped state clears the navigation info display to prevent lingering step instructions from being displayed.

Creating icons for maneuvers

The GMSNavigationManeuver enum defines each possible maneuver that could occur while navigating, and you can get the maneuver for a given step from the maneuver property of GMSNavigationStepInfo.

You must create maneuver icons and pair them with their associated maneuvers. For some maneuvers, you can set up a one-to-one mapping to an icon, such as GMSNavigationManeuverDestinationLeft and GMSNavigationManeuverDestinationRight. However, since some maneuvers share characteristics with other meaneuvers, you might want to map more than one maneuver to a single icon. For example GMSNavigationManeuverTurnLeft and GMSNavigationManeuverOnRampLeft could both map to the left turn icon.

Some maneuvers contain an additional “Clockwise” or “CounterClockwise” label, which the SDK determines based on the driving side of a country. For example, in countries where driving is on the left side of the road, drivers take a roundabout or U-turn in a clockwise direction, whereas right-side-of-the-road countries go counterclockwise. The Navigation SDK detects whether a maneuver occurs in left- or right-side traffic and outputs the appropriate maneuver. Therefore, your maneuver icon may be different for a clockwise versus a counterclockwise maneuver.

Expand to see examples icons for different maneuvers

Sample Icon TurnByTurn Maneuvers
DEPART
UNKNOWN
STRAIGHT
ON_RAMP_UNSPECIFIED
OFF_RAMP_UNSPECIFIED
NAME_CHANGE
TURN_RIGH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
OFF_RAMP_LEFT
FORK_RIGHT
TURN_KEEP_RIGHT
ON_RAMP_KEEP_RIGHT
OFF_RAMP_KEEP_RIGHT
FORK_LEFT
TURN_KEEP_LEFT
ON_RAMP_KEEP_LEFT
OFF_RAMP_KEEP_LEFT
MERGE_UNSPECIFIED
DESTINATION
DESTINATION_RIGHT
DESTINATION_LEFT
FERRY_BOAT
FERRY_TRAIN

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2022-10-05 UTC.