Search in sources :

Example 26 with Point

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;
}
Also used : MarkerOptions(com.mapbox.mapboxsdk.annotations.MarkerOptions) Point(com.mapbox.geojson.Point)

Example 27 with Point

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);
}
Also used : Point(com.mapbox.geojson.Point) RouteInformation(com.mapbox.services.android.navigation.v5.navigation.camera.RouteInformation) BaseTest(com.mapbox.services.android.navigation.ui.v5.BaseTest) Test(org.junit.Test)

Example 28 with Point

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);
    }
}
Also used : OffRouteEvent(com.mapbox.services.android.navigation.ui.v5.route.OffRouteEvent) Point(com.mapbox.geojson.Point)

Example 29 with Point

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);
    }
}
Also used : Point(com.mapbox.geojson.Point) Point(com.mapbox.geojson.Point)

Example 30 with Point

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);
}
Also used : NavigationViewOptions(com.mapbox.services.android.navigation.ui.v5.NavigationViewOptions) Point(com.mapbox.geojson.Point)

Aggregations

Point (com.mapbox.geojson.Point)72 Test (org.junit.Test)31 BaseTest (com.mapbox.services.android.navigation.v5.BaseTest)29 Location (android.location.Location)18 RouteProgress (com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress)17 LineString (com.mapbox.geojson.LineString)15 ArrayList (java.util.ArrayList)10 LegStep (com.mapbox.api.directions.v5.models.LegStep)9 LatLng (com.mapbox.mapboxsdk.geometry.LatLng)7 Feature (com.mapbox.geojson.Feature)4 NavigationRoute (com.mapbox.services.android.navigation.v5.navigation.NavigationRoute)4 DirectionsResponse (com.mapbox.api.directions.v5.models.DirectionsResponse)3 DirectionsRoute (com.mapbox.api.directions.v5.models.DirectionsRoute)3 CameraPosition (com.mapbox.mapboxsdk.camera.CameraPosition)3 LatLngBounds (com.mapbox.mapboxsdk.geometry.LatLngBounds)3 Gson (com.google.gson.Gson)2 GsonBuilder (com.google.gson.GsonBuilder)2 RouteOptions (com.mapbox.api.directions.v5.models.RouteOptions)2 MarkerOptions (com.mapbox.mapboxsdk.annotations.MarkerOptions)2 BaseTest (com.mapbox.services.android.navigation.ui.v5.BaseTest)2