mapbox / mapbox-navigation-android

Mapbox Navigation SDK for Android
https://docs.mapbox.com/android/navigation/overview/
Other
622 stars 318 forks source link

How to detect turning left or right ? #918

Closed atomike-toxic closed 6 years ago

atomike-toxic commented 6 years ago

Bonjour, ayant créer un sujet du même type #874 Vous m'avez dis d'utiliser RouteProgress#currentLegProgress()#upcomingStep()#manevuer() Cela fais une semaine que j'essaye de le faire fonctionner mais ma syntaxe ne dois pas être bonne. Ensuite sur Stackoverflow on m'a dis d'utiliser String modifier = yourJsonObj.getString("modifier"); Donc je suis un peu perdu. Ensuite j'ai fouiller dans les documentations de StepManeuver et j'ai trouvé ceci public static final String STEP_MANEUVER_MODIFIER_RIGHT = "right"; Est-ce qu'on peut l'utiliser et le vérifier dans une condition ?

En fait, je suis étudiant dans un lycée français et mon projet est de vérifier quand l'utilisateur doit tourné à droite ou à gauche. Par exemple si il doit tourné à gauche je vais devoir envoyer une information à un Arduino par Bluetooth pour faire fonctionner une LED. Donc mon but est de vérifier "modifier".

Et je me demandais aussi pourquoi utiliser ProgressChangeListener alors que l'itinéraire est en cours. j'ai vu aussi getModifier(), comment le met-on en oeuvre ?

Avez vous une solution ? Merci de votre réponse, cela m'aide grandement.

danesfeder commented 6 years ago

Hey @atomike-toxic, I don't speak French, but I had some fellow Mapboxers help me out here.

I think what you're looking for is in the StepManeuver: the type and modifier.

StepManeuver#type() returns the type of the maneuver (turn, merge, fork, etc.) StepManeuver#modifier() returns direction or further detail on the maneuver type.

StepManeuver maneuver = routeProgress.currentLegProgress().upcomingStep().maneuver();
if (maneuver.type().contains(STEP_MANEUVER_TYPE_TURN) && manevuer.modfifier().contains(STEP_MANEUVER_MODIFIER_RIGHT) {
     // Execute code for turning right
}

Hope this helps, thanks! In the future, please ask these types of questions on StackOverflow, so if anyone else has the same question they will be able to check out the same answer https://stackoverflow.com/questions/tagged/mapbox