GoogleNavigation Framework Reference
Stay organized with collections
Save and categorize content based on your preferences.
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.
-
Declaration
Objective-C
- (instancetype)init NS_UNAVAILABLE;
-
Adds a listener. The listener is held with a weak reference.
-
Return Value
Returns YES if the listener was removed. Returns NO if the object was not a listener.
-
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, -stopUpdatingLocation
should be called when road-snapped location is no longer required.
Declaration
Swift
func startUpdatingLocation()
Objective-C
- (void)startUpdatingLocation;
-
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;
-
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;
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 2025-08-27 UTC.
[null,null,["Last updated 2025-08-27 UTC."],[[["\u003cp\u003e\u003ccode\u003eGMSRoadSnappedLocationProvider\u003c/code\u003e delivers road-snapped location updates, similar to \u003ccode\u003eCLLocationManager\u003c/code\u003e but optimized for driving scenarios.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can add and remove listeners to receive location updates using \u003ccode\u003eaddListener:\u003c/code\u003e and \u003ccode\u003eremoveListener:\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eLocation updates are managed by \u003ccode\u003estartUpdatingLocation\u003c/code\u003e and \u003ccode\u003estopUpdatingLocation\u003c/code\u003e, enabling and disabling the delivery of location events.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eallowsBackgroundLocationUpdates\u003c/code\u003e property controls whether updates continue when the app is in the background.\u003c/p\u003e\n"]]],[],null,["# GoogleNavigation Framework Reference\n\nGMSRoadSnappedLocationProvider\n==============================\n\n @interface GMSRoadSnappedLocationProvider : NSObject\n\nProvides updates of the device's location. This class functions similarly to CLLocationManager,\nexcept that if the device is in driving mode, the location updates is snapped to the nearest\nroad.\n\nThis class is not intended for subclassing.\n- `\n ``\n ``\n `\n\n ### [-init](#/c:objc(cs)GMSRoadSnappedLocationProvider(im)init)\n\n `\n ` \n Unavailable \n\n #### Declaration\n\n Objective-C \n\n - (instancetype)init NS_UNAVAILABLE;\n\n- `\n ``\n ``\n `\n\n ### [-addListener:](#/c:objc(cs)GMSRoadSnappedLocationProvider(im)addListener:)\n\n `\n ` \n Adds a listener. The listener is held with a weak reference. \n\n #### Declaration\n\n Swift \n\n func add(_ listener: any ../Protocols/GMSRoadSnappedLocationProviderListener.html)\n\n Objective-C \n\n - (void)addListener:\n (nonnull id\u003c../Protocols/GMSRoadSnappedLocationProviderListener.html\u003e)listener;\n\n #### Parameters\n\n |------------------|------------------------------------------------------------------------------------------------------------------------------------------|\n | ` `*listener*` ` | An object conforming to the [GMSRoadSnappedLocationProviderListener](../Protocols/GMSRoadSnappedLocationProviderListener.html) protocol. |\n\n- `\n ``\n ``\n `\n\n ### [-removeListener:](#/c:objc(cs)GMSRoadSnappedLocationProvider(im)removeListener:)\n\n `\n ` \n Removes a listener. \n\n #### Declaration\n\n Swift \n\n func remove(_ listener: any ../Protocols/GMSRoadSnappedLocationProviderListener.html) -\u003e Bool\n\n Objective-C \n\n - (BOOL)removeListener:\n (nonnull id\u003c../Protocols/GMSRoadSnappedLocationProviderListener.html\u003e)listener;\n\n #### Parameters\n\n |------------------|------------------------------------------------------------------------------------------------------------------------------------------|\n | ` `*listener*` ` | An object conforming to the [GMSRoadSnappedLocationProviderListener](../Protocols/GMSRoadSnappedLocationProviderListener.html) protocol. |\n\n #### Return Value\n\n Returns YES if the listener was removed. Returns NO if the object was not a listener.\n- `\n ``\n ``\n `\n\n ### [-startUpdatingLocation](#/c:objc(cs)GMSRoadSnappedLocationProvider(im)startUpdatingLocation)\n\n `\n ` \n Starts updating the device's road-snapped location. After this is called, the delegate will start\n receiving location update events.\n\n In order to avoid battery drain or unintended logging of device location, [-stopUpdatingLocation](../Classes/GMSRoadSnappedLocationProvider.html#/c:objc(cs)GMSRoadSnappedLocationProvider(im)stopUpdatingLocation)\n should be called when road-snapped location is no longer required. \n\n #### Declaration\n\n Swift \n\n func startUpdatingLocation()\n\n Objective-C \n\n - (void)startUpdatingLocation;\n\n- `\n ``\n ``\n `\n\n ### [-stopUpdatingLocation](#/c:objc(cs)GMSRoadSnappedLocationProvider(im)stopUpdatingLocation)\n\n `\n ` \n Stops updating the device's road-snapped location. In order to avoid battery drain or unintended\n logging of device location, this method should be called when the listener is no longer required. \n\n #### Declaration\n\n Swift \n\n func stopUpdatingLocation()\n\n Objective-C \n\n - (void)stopUpdatingLocation;\n\n- `\n ``\n ``\n `\n\n ### [allowsBackgroundLocationUpdates](#/c:objc(cs)GMSRoadSnappedLocationProvider(py)allowsBackgroundLocationUpdates)\n\n `\n ` \n Whether the delegate should still receive location updates when the app is in the background.\n Defaults to NO. \n\n #### Declaration\n\n Swift \n\n var allowsBackgroundLocationUpdates: Bool { get set }\n\n Objective-C \n\n @property (nonatomic) BOOL allowsBackgroundLocationUpdates;"]]