Listen for navigation events

  • The Navigation SDK for iOS allows you to respond to real-time navigation events like route changes, arrival, and location updates using listeners.

  • GMSRoadSnappedLocationProviderListener and GMSNavigatorListener protocols handle events like location updates, speeding, and destination arrival.

  • Location updates can be managed for real-time tracking and background operation, impacting battery life.

  • The GMSNavigator provides methods to track and respond to waypoint arrivals, route changes, time and distance to destination, traffic flow, speeding percentage, and suggested lighting mode.

  • GMSNavigatorDelegate and GMSRoadSnappedLocationProviderDelegate are deprecated and replaced by GMSRoadSnappedLocationProviderListener and GMSNavigatorListener.

Use this guide to enable your app to listen and respond to a variety of events that change as a user navigates along a route. This guide does not cover defining a route, only responding to events along a route.

Overview

The Navigation SDK for iOS provides you with listeners associated with the location of the user and conditions along the route and important time and distance data. On the view controller of the map, your app needs to adopt the protocols for these listeners: GMSRoadSnappedLocationProviderListener and GMSNavigatorListener.

This list shows the listener methods available for navigation events:

See the code

Declaring conformance to the required protocols

Before implementing the navigation methods, the view controller must adopt the protocols:

Swift

class ViewController:
  UIViewController,
  GMSNavigatorListener,
  GMSRoadSnappedLocationProviderListener
{
}