GMSLocationSimulator
@interface GMSLocationSimulator : NSObject
A class you can use to simulate a device location for testing purposes.
-
Unavailable
Declaration
Objective-C
- (instancetype)init NS_UNAVAILABLE;
-
Starts simulating travel along the route currently set on the
GMSNavigator
. If theGMSNavigator
does not have a route, this does nothing.Declaration
Swift
func simulateLocationsAlongExistingRoute()
Objective-C
- (void)simulateLocationsAlongExistingRoute;
-
Calculates a route to the given waypoints and simulates travel along this route. The new route will use the travel mode that is set on the
GMSMapView
.Travel will be started just before the callback is called with
GMSRouteStatusOK
. If the callback returns any value other thanGMSRouteStatusOK
, no simulation will start. If any other simulator methods are called before the route is generated, route generation will be canceled and the callback will be called withGMSRouteStatusCanceled
.Declaration
Swift
func simulateAlongNewRoute(toDestinations destinations: [GMSNavigationWaypoint], callback: @escaping GMSRouteStatusCallback)
Objective-C
- (void)simulateAlongNewRouteToDestinations: (nonnull NSArray<GMSNavigationWaypoint *> *)destinations callback: (nonnull GMSRouteStatusCallback)callback;
Parameters
destinations
The list of destinations for the route that will be simulated.
callback
A block that will be called when the route becomes available or fails.
-
Calculates a route to the given waypoints, and simulates travel along this route. The new route will use the travel mode which is set on the
GMSMapView
.Travel starts right before the callback is invoked with
GMSRouteStatusOK
. If the callback returns a value other thanGMSRouteStatusOK
, then no simulation starts. If any other simulator methods are called before the route is generated, then route generation will be canceled, and the callback will be called withGMSRouteStatusCanceled
.Declaration
Swift
func simulateAlongNewRoute(toDestinations destinations: [GMSNavigationWaypoint], routingOptions: GMSNavigationRoutingOptions, callback: @escaping GMSRouteStatusCallback)
Objective-C
- (void)simulateAlongNewRouteToDestinations: (nonnull NSArray<GMSNavigationWaypoint *> *)destinations routingOptions: (nonnull GMSNavigationRoutingOptions *) routingOptions callback: (nonnull GMSRouteStatusCallback)callback;
Parameters
destinations
The list of destinations for the route that will be simulated.
routingOptions
The routing logic that will determine the returned route.
callback
A block that will be called when the route becomes available or fails.
-
Starts simulating the device location at a fixed coordinate.
Declaration
Swift
func simulateLocation(at coordinate: CLLocationCoordinate2D)
Objective-C
- (void)simulateLocationAtCoordinate:(CLLocationCoordinate2D)coordinate;
-
Stops simulating the device location if it is currently being simulated.
Declaration
Swift
func stopSimulation()
Objective-C
- (void)stopSimulation;
-
Diplays a navigation prompt with fake data for testing purposes.
Declaration
Swift
func simulateNavigationPrompt()
Objective-C
- (void)simulateNavigationPrompt;
-
Displays a dummy traffic prompt for testing purposes.
Declaration
Swift
func simulateTrafficIncidentReport()
Objective-C
- (void)simulateTrafficIncidentReport;
-
Whether the simulation is currently paused. If this is set to
YES
whilst simulating along a route, then location updates will still be sent periodically, but the location will stop advancing along the route.Declaration
Swift
var isPaused: Bool { get set }
Objective-C
@property (nonatomic, getter=isPaused) BOOL paused;
-
Whether to avoid highways when simulating travel to destinations with the
-simulateAlongNewRouteToDestinations:callback:
method. Defaults to NO.Declaration
Swift
var avoidsHighways: Bool { get set }
Objective-C
@property (nonatomic) BOOL avoidsHighways;
-
Whether to avoid toll roads when simulating travel to destinations with the
-simulateAlongNewRouteToDestinations:callback:
method. Defaults to NO.Declaration
Swift
var avoidsTolls: Bool { get set }
Objective-C
@property (nonatomic) BOOL avoidsTolls;
-
Whether to avoid ferries when simulating travel to destinations with the
-simulateAlongNewRouteToDestinations:callback:
method. Defaults to YES.Declaration
Swift
var avoidsFerries: Bool { get set }
Objective-C
@property (nonatomic) BOOL avoidsFerries;
-
The speed multiplier to use when simulating travel along a route. The value of this property must be positive. Attempting to set a non-positive value will have no effect. The default value is 1.0.
Declaration
Swift
var speedMultiplier: Float { get set }
Objective-C
@property (nonatomic) float speedMultiplier;
-
Whether the simulated location should jitter randomly.
Declaration
Swift
var isLocationJitteringEnabled: Bool { get set }
Objective-C
@property (nonatomic, assign, unsafe_unretained, readwrite, getter=isLocationJitteringEnabled) BOOL locationJitteringEnabled;
-
Set license plate restriction with current vehicle’s last digit of license plate and country code. This allows us to route around certain types of road restrictions which are based on license plate number. This will only apply to
-simulateAlongNewRouteToDestinations
calls made after this value is set.Set to nil if there is no license plate restriction. Default to nil.
Declaration
Swift
var licensePlateRestriction: GMSNavigationLicensePlateRestriction? { get set }
Objective-C
@property (nonatomic, nullable) GMSNavigationLicensePlateRestriction *licensePlateRestriction;