public class MockLocationEngine
extends com.mapbox.services.android.telemetry.location.LocationEngine
DirectionsRoute. Once the route is passed in the mocking is automatically started. It goes step by step
within the directions route. This allows for long routing without memory issues. You have the option to either use
the default values for delay (1 second), speed (30m/h), and noisyGps (false) or you can pass in your own values when
constructing this object.| Constructor and Description |
|---|
MockLocationEngine()
Create a
MockLocationEngine instance using the default parameters. |
MockLocationEngine(int delay,
int speed,
boolean noisyGps)
Create a
MockLocationEngine instance with custom parameters. |
| Modifier and Type | Method and Description |
|---|---|
void |
activate()
Connect all the location listeners.
|
void |
deactivate()
Stops mocking the user location along the route.
|
int |
getDelay() |
android.location.Location |
getLastLocation()
If the lastLocation is not null, this method will return the last location as expected.
|
int |
getSpeed() |
boolean |
isConnected()
While the
MockLocationEngine is in use, you are always connected to it. |
boolean |
isNoisyGps() |
void |
moveToLocation(com.mapbox.services.commons.models.Position position) |
com.mapbox.services.android.telemetry.location.LocationEngine.Type |
obtainType() |
void |
removeLocationUpdates()
Removes location updates for the LocationListener.
|
void |
requestLocationUpdates()
Nothing needs to happen here since we are mocking the user location along a route.
|
void |
setLastLocation(com.mapbox.services.commons.models.Position currentPosition) |
void |
setRoute(com.mapbox.services.api.directions.v5.models.DirectionsRoute route)
Use this method to pass in a route and start the mocking immediately.
|
addLocationEngineListener, getFastestInterval, getInterval, getPriority, getSmallestDisplacement, isBetterLocation, removeLocationEngineListener, setFastestInterval, setInterval, setPriority, setSmallestDisplacementpublic MockLocationEngine()
MockLocationEngine instance using the default parameters.public MockLocationEngine(int delay,
int speed,
boolean noisyGps)
MockLocationEngine instance with custom parameters.delay - the frequency in which the gps position is updated in milliseconds.speed - the speed the user is traveling in miles per hour.noisyGps - true if you want the mock positions to become noisy.public void activate()
activate in class com.mapbox.services.android.telemetry.location.LocationEnginepublic void deactivate()
deactivate in class com.mapbox.services.android.telemetry.location.LocationEnginepublic boolean isConnected()
MockLocationEngine is in use, you are always connected to it.isConnected in class com.mapbox.services.android.telemetry.location.LocationEngine@Nullable public android.location.Location getLastLocation()
getLastLocation in class com.mapbox.services.android.telemetry.location.LocationEngineLocation which represents the last mock location.public void setLastLocation(com.mapbox.services.commons.models.Position currentPosition)
public boolean isNoisyGps()
public int getSpeed()
public int getDelay()
public void requestLocationUpdates()
requestLocationUpdates in class com.mapbox.services.android.telemetry.location.LocationEnginepublic void removeLocationUpdates()
removeLocationUpdates in class com.mapbox.services.android.telemetry.location.LocationEnginepublic com.mapbox.services.android.telemetry.location.LocationEngine.Type obtainType()
obtainType in class com.mapbox.services.android.telemetry.location.LocationEnginepublic void moveToLocation(com.mapbox.services.commons.models.Position position)
public void setRoute(com.mapbox.services.api.directions.v5.models.DirectionsRoute route)
route - a DirectionsRoute which you'd like to mock the user location on.