Search in sources :

Example 1 with OffRouteEvent

use of com.mapbox.services.android.navigation.ui.v5.route.OffRouteEvent in project mapbox-navigation-android by mapbox.

the class NavigationViewModel method userOffRoute.

/**
 * Listener used to update when a user has gone off-route.
 * <p>
 * This is being used as a cue for a re-route UX / to fetch a new route to
 * keep the user on course.
 * <p>
 * Added to {@link com.mapbox.services.android.navigation.v5.navigation.MapboxNavigation}.
 *
 * @param location given to create a new origin
 * @since 0.6.0
 */
@Override
public void userOffRoute(Location location) {
    if (hasNetworkConnection()) {
        Point newOrigin = Point.fromLngLat(location.getLongitude(), location.getLatitude());
        this.offRouteEvent.setValue(new OffRouteEvent(newOrigin, routeProgress));
        isOffRoute.setValue(true);
    }
}
Also used : OffRouteEvent(com.mapbox.services.android.navigation.ui.v5.route.OffRouteEvent) Point(com.mapbox.geojson.Point)

Aggregations

Point (com.mapbox.geojson.Point)1 OffRouteEvent (com.mapbox.services.android.navigation.ui.v5.route.OffRouteEvent)1