Search in sources :

Example 1 with MockLocationEngine

use of com.mapbox.services.android.navigation.v5.location.MockLocationEngine in project mapbox-navigation-android by mapbox.

the class MockNavigationActivity method onMapReady.

@Override
public void onMapReady(MapboxMap mapboxMap) {
    this.mapboxMap = mapboxMap;
    locationLayerPlugin = new LocationLayerPlugin(mapView, mapboxMap, null);
    locationLayerPlugin.setLocationLayerEnabled(LocationLayerMode.NAVIGATION);
    navigationMapRoute = new NavigationMapRoute(navigation, mapView, mapboxMap);
    mapboxMap.addOnMapClickListener(this);
    Snackbar.make(mapView, "Tap map to place waypoint", BaseTransientBottomBar.LENGTH_LONG).show();
    locationEngine = new MockLocationEngine(1000, 50, true);
    mapboxMap.setLocationSource(locationEngine);
    newOrigin();
}
Also used : LocationLayerPlugin(com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerPlugin) NavigationMapRoute(com.mapbox.services.android.navigation.ui.v5.route.NavigationMapRoute) MockLocationEngine(com.mapbox.services.android.navigation.v5.location.MockLocationEngine)

Example 2 with MockLocationEngine

use of com.mapbox.services.android.navigation.v5.location.MockLocationEngine in project mapbox-navigation-android by mapbox.

the class LocationViewModel method activateMockLocationEngine.

/**
 * Activates a new {@link MockLocationEngine} with the given
 * {@link DirectionsRoute}.
 *
 * @param route to be mocked
 */
private void activateMockLocationEngine(DirectionsRoute route) {
    LocationEngine locationEngine = new MockLocationEngine(1000, 30, false);
    ((MockLocationEngine) locationEngine).setRoute(route);
    locationEngine.activate();
    this.locationEngine.setValue(locationEngine);
}
Also used : LocationEngine(com.mapbox.services.android.telemetry.location.LocationEngine) MockLocationEngine(com.mapbox.services.android.navigation.v5.location.MockLocationEngine) MockLocationEngine(com.mapbox.services.android.navigation.v5.location.MockLocationEngine)

Example 3 with MockLocationEngine

use of com.mapbox.services.android.navigation.v5.location.MockLocationEngine in project mapbox-navigation-android by mapbox.

the class MockNavigationActivity method newOrigin.

private void newOrigin() {
    if (mapboxMap != null) {
        LatLng latLng = Utils.getRandomLatLng(new double[] { -77.1825, 38.7825, -76.9790, 39.0157 });
        ((MockLocationEngine) locationEngine).setLastLocation(Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude()));
        mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, 12));
        mapboxMap.setMyLocationEnabled(true);
        mapboxMap.getTrackingSettings().setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW);
    }
}
Also used : LatLng(com.mapbox.mapboxsdk.geometry.LatLng) MockLocationEngine(com.mapbox.services.android.navigation.v5.location.MockLocationEngine)

Example 4 with MockLocationEngine

use of com.mapbox.services.android.navigation.v5.location.MockLocationEngine in project mapbox-navigation-android by mapbox.

the class RerouteActivity method onMapReady.

@SuppressLint("MissingPermission")
@Override
public void onMapReady(MapboxMap mapboxMap) {
    this.mapboxMap = mapboxMap;
    mapboxMap.setOnMapClickListener(this);
    locationLayerPlugin = new LocationLayerPlugin(mapView, mapboxMap, null);
    locationLayerPlugin.setLocationLayerEnabled(LocationLayerMode.NAVIGATION);
    // Setup the mockLocationEngine
    mockLocationEngine = new MockLocationEngine(1000, 30, false);
    mockLocationEngine.addLocationEngineListener(this);
    navigation.setLocationEngine(mockLocationEngine);
    // Acquire the navigation route
    getRoute(origin, destination, null);
}
Also used : LocationLayerPlugin(com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerPlugin) MockLocationEngine(com.mapbox.services.android.navigation.v5.location.MockLocationEngine) SuppressLint(android.annotation.SuppressLint)

Aggregations

MockLocationEngine (com.mapbox.services.android.navigation.v5.location.MockLocationEngine)4 LocationLayerPlugin (com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerPlugin)2 SuppressLint (android.annotation.SuppressLint)1 LatLng (com.mapbox.mapboxsdk.geometry.LatLng)1 NavigationMapRoute (com.mapbox.services.android.navigation.ui.v5.route.NavigationMapRoute)1 LocationEngine (com.mapbox.services.android.telemetry.location.LocationEngine)1