mapbox-navigation-android icon indicating copy to clipboard operation
mapbox-navigation-android copied to clipboard

Turn by Turn navigation query?

Open harshjain-dev opened this issue 8 years ago • 9 comments

Turn by Turn Navigation

I am using your SDK for turn by turn navigation in android. I need to ask how to navigate in real time getting the real-time location. Right now what's happening is when I start the turn by turn navigation it goes to the destination automatically but I want when the user moves it should show the navigation according to it. How to do in-app programmatically. And also I need to find out when the navigation is stopped can I get information about the drive or travel.

Thanks in advance.

cc @cammace @danesfeder @bsudekum

harshjain-dev avatar Feb 19 '18 08:02 harshjain-dev

Hey @Harshjain2094, would you be able to provide the version of the SDK you're using and a code snippet of how you are using the SDK? Thanks!

danesfeder avatar Feb 23 '18 11:02 danesfeder

Hey, @danesfeder

I have implemented these files in gradle file of app:

implementation('com.mapbox.mapboxsdk:mapbox-android-sdk:5.4.1@aar') { transitive = true } implementation 'com.mapbox.mapboxsdk:mapbox-android-navigation:0.9.0' implementation('com.mapbox.mapboxsdk:mapbox-android-navigation-ui:0.9.0') { transitive = true }

And the code to start navigation is this :

   **_MapboxNavigationOptions navigationOptions = MapboxNavigationOptions.builder()
            .unitType(NavigationUnitType.TYPE_METRIC)
            .build();
    Log.d("NewActivity","onMapReady");
    NavigationViewOptions options = NavigationViewOptions.builder()
            .origin(originPosition)
            .destination(destinationPosition)
            .awsPoolId(null)
            .shouldSimulateRoute(true)
            .navigationListener(this)
            .navigationOptions(navigationOptions)
            .directionsProfile(DirectionsCriteria.PROFILE_DRIVING)
            .build();

    navigationView.startNavigation(options);_**

I think I am getting an issue with

shouldsimulateRoute()

method because I have given both values true and false still it won't navigation in real time location change. What are other possible ways?

Thanks for replying.

harshjain-dev avatar Feb 23 '18 11:02 harshjain-dev

@Harshjain2094 Yeah, you are correct, you can remove .shouldSimulateRoute() completely (the default is false).

As far as not getting update when this is false, are you in a building? Have you been driving / outside? GPS can struggle in indoors, regardless of our settings. Other than that, I would make sure you have the correct location permissions requested ACCESS_FINE_LOCATION and ACCESS_COARSE_LOCATION

danesfeder avatar Feb 23 '18 11:02 danesfeder

@danesfeder So, I should remove this line and could when I start navigation it would give real-time directions and navigate with it?

I just need to ask one more thing when the travel is finished i.e the rider has reached the destination if there any method to get information about time, distance and ride fully completed or not?

harshjain-dev avatar Feb 23 '18 11:02 harshjain-dev

@Harshjain2094 Yes, that's correct. We start up a LocationEngine that begins pushing Location updates to the SDK for processing.

To listen to the NavigationVew, you can use https://www.mapbox.com/android-docs/navigation/overview/navigation-ui/#listening-to-the-navigationview

In particular, ProgressChangeListener and check with RouteUtils#isArrivalEvent(RouteProgress) -- this will be true only during arrival of a LegStep

danesfeder avatar Feb 23 '18 12:02 danesfeder

okay, thanks it'll help a lot. @danesfeder Thanks a ton.

harshjain-dev avatar Feb 23 '18 12:02 harshjain-dev

@Harshjain2094 no problem, should be good to close here. Feel free to create a new ticket if you run into any other issues.

danesfeder avatar Feb 23 '18 16:02 danesfeder

@danesfeder thanks for reply related to this question i want to update with gps location so i remove this line .shouldSimulateRoute() and now how to update location?any method

Meerz avatar May 04 '18 12:05 Meerz

@Harshjain2094 bro will you help me in this , i have same issue you have, navigation is not working after silmulateRoute set to the false . if i start navigation after removing simulateRoute , always show "You have arrived".

beabhishek avatar Feb 27 '20 12:02 beabhishek