# GMSRoadSnappedLocationProvider

    @interface GMSRoadSnappedLocationProvider : NSObject

Provides updates of the device's location. This class functions similarly to CLLocationManager,
except that if the device is in driving mode, the location updates is snapped to the nearest
road.

This class is not intended for subclassing.
- `


  ### [-init](https://developers.google.com/maps/documentation/navigation/ios-sdk/reference/objc/Classes/GMSRoadSnappedLocationProvider#/c:objc(cs)GMSRoadSnappedLocationProvider(im)init)


  ` Unavailable

  #### Declaration

  Objective-C

      - (instancetype)init NS_UNAVAILABLE;

- `


  ### [-addListener:](https://developers.google.com/maps/documentation/navigation/ios-sdk/reference/objc/Classes/GMSRoadSnappedLocationProvider#/c:objc(cs)GMSRoadSnappedLocationProvider(im)addListener:)


  ` Adds a listener. The listener is held with a weak reference.

  #### Declaration

  Swift

      func add(_ listener: any https://developers.google.com/maps/documentation/navigation/ios-sdk/reference/objc/Protocols/GMSRoadSnappedLocationProviderListener.html)

  Objective-C

      - (void)addListener:
          (nonnull id<https://developers.google.com/maps/documentation/navigation/ios-sdk/reference/objc/Protocols/GMSRoadSnappedLocationProviderListener.html>)listener;

  #### Parameters

  |---|---|
  | ` listener ` | An object conforming to the `https://developers.google.com/maps/documentation/navigation/ios-sdk/reference/objc/Protocols/GMSRoadSnappedLocationProviderListener.html` protocol. |

- `


  ### [-removeListener:](https://developers.google.com/maps/documentation/navigation/ios-sdk/reference/objc/Classes/GMSRoadSnappedLocationProvider#/c:objc(cs)GMSRoadSnappedLocationProvider(im)removeListener:)


  ` Removes a listener.

  #### Declaration

  Swift

      func remove(_ listener: any https://developers.google.com/maps/documentation/navigation/ios-sdk/reference/objc/Protocols/GMSRoadSnappedLocationProviderListener.html) -> Bool

  Objective-C

      - (BOOL)removeListener:
          (nonnull id<https://developers.google.com/maps/documentation/navigation/ios-sdk/reference/objc/Protocols/GMSRoadSnappedLocationProviderListener.html>)listener;

  #### Parameters

  |---|---|
  | ` listener ` | An object conforming to the `https://developers.google.com/maps/documentation/navigation/ios-sdk/reference/objc/Protocols/GMSRoadSnappedLocationProviderListener.html` protocol. |

  #### Return Value

  Returns YES if the listener was removed. Returns NO if the object was not a listener.
- `


  ### [-startUpdatingLocation](https://developers.google.com/maps/documentation/navigation/ios-sdk/reference/objc/Classes/GMSRoadSnappedLocationProvider#/c:objc(cs)GMSRoadSnappedLocationProvider(im)startUpdatingLocation)


  ` Starts updating the device's road-snapped location. After this is called, the delegate will start
  receiving location update events.

  In order to avoid battery drain or unintended logging of device location, `https://developers.google.com/maps/documentation/navigation/ios-sdk/reference/objc/Classes/GMSRoadSnappedLocationProvider.html#/c:objc(cs)GMSRoadSnappedLocationProvider(im)stopUpdatingLocation`
  should be called when road-snapped location is no longer required.

  #### Declaration

  Swift

      func startUpdatingLocation()

  Objective-C

      - (void)startUpdatingLocation;

- `


  ### [-stopUpdatingLocation](https://developers.google.com/maps/documentation/navigation/ios-sdk/reference/objc/Classes/GMSRoadSnappedLocationProvider#/c:objc(cs)GMSRoadSnappedLocationProvider(im)stopUpdatingLocation)


  ` Stops updating the device's road-snapped location. In order to avoid battery drain or unintended
  logging of device location, this method should be called when the listener is no longer required.

  #### Declaration

  Swift

      func stopUpdatingLocation()

  Objective-C

      - (void)stopUpdatingLocation;

- `


  ### [allowsBackgroundLocationUpdates](https://developers.google.com/maps/documentation/navigation/ios-sdk/reference/objc/Classes/GMSRoadSnappedLocationProvider#/c:objc(cs)GMSRoadSnappedLocationProvider(py)allowsBackgroundLocationUpdates)


  ` Whether the delegate should still receive location updates when the app is in the background.
  Defaults to NO.

  #### Declaration

  Swift

      var allowsBackgroundLocationUpdates: Bool { get set }

  Objective-C

      @property (nonatomic) BOOL allowsBackgroundLocationUpdates;