use of com.mapbox.geojson.Point in project mapbox-navigation-android by mapbox.
the class RerouteActivity method onMapClick.
@Override
public void onMapClick(@NonNull LatLng point) {
if (!running || mapboxMap == null) {
return;
}
mapboxMap.addMarker(new MarkerOptions().position(point));
mapboxMap.setOnMapClickListener(null);
Point newDestination = Point.fromLngLat(point.getLongitude(), point.getLatitude());
mockLocationEngine.moveToLocation(newDestination);
destination = Point.fromLngLat(point.getLongitude(), point.getLatitude());
tracking = false;
}
use of com.mapbox.geojson.Point in project mapbox-navigation-android by mapbox.
the class DynamicCameraTest method onInformationFromLocationAndProgress_engineCreatesCorrectTarget.
@Test
public void onInformationFromLocationAndProgress_engineCreatesCorrectTarget() throws Exception {
RouteInformation routeInformation = RouteInformation.create(null, buildDefaultLocationUpdate(-77.0339782574523, 38.89993519985637), buildDefaultRouteProgress(null));
Point target = cameraEngine.target(routeInformation);
double lng = target.longitude();
assertEquals(-77.0339782574523, lng);
double lat = target.latitude();
assertEquals(38.89993519985637, lat);
}
use of com.mapbox.geojson.Point 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);
}
}
use of com.mapbox.geojson.Point in project mapbox-navigation-android by mapbox.
the class RouteViewModel method cacheRouteDestination.
/**
* Looks at the given {@link DirectionsRoute} and extracts the destination based on
* the last {@link LegStep} maneuver.
*/
private void cacheRouteDestination() {
if (routeOptions != null && !routeOptions.coordinates().isEmpty()) {
List<Point> coordinates = routeOptions.coordinates();
int destinationCoordinate = coordinates.size() - 1;
Point destinationPoint = coordinates.get(destinationCoordinate);
destination.setValue(destinationPoint);
}
}
use of com.mapbox.geojson.Point in project mapbox-navigation-android by mapbox.
the class NavigationFragment method onNavigationReady.
@Override
public void onNavigationReady() {
Point origin = Point.fromLngLat(ORIGIN_LONGITUDE, ORIGIN_LATITUDE);
Point destination = Point.fromLngLat(DESTINATION_LONGITUDE, DESTINATION_LATITUDE);
NavigationViewOptions options = NavigationViewOptions.builder().origin(origin).destination(destination).shouldSimulateRoute(true).navigationListener(this).build();
navigationView.startNavigation(options);
}
Aggregations