NavigationView with useroffroute MapBox Android

huangapple go评论122阅读模式
英文:

NavigationView with useroffroute MapBox Android

问题

  1. public class mapbox extends AppCompatActivity {
  2. // ... (other imports and variable declarations)
  3. @Override
  4. protected void onCreate(Bundle savedInstanceState) {
  5. super.onCreate(savedInstanceState);
  6. Mapbox.getInstance(this, getString(R.string.mapbox_access_token));
  7. setContentView(R.layout.activity_mapbox);
  8. button = findViewById(R.id.button);
  9. MapboxNavigationOptions options = MapboxNavigationOptions.builder().isDebugLoggingEnabled(true).build();
  10. navigation = new MapboxNavigation(getApplicationContext(), getString(R.string.mapbox_access_token), options);
  11. navigation.addOffRouteListener(new OffRouteListener() {
  12. @Override
  13. public void userOffRoute(Location location) {
  14. Toast.makeText(getApplicationContext(), "Off route detected.........", Toast.LENGTH_SHORT).show();
  15. // Make sure you call for a new DirectionsRoute object
  16. // and end by calling MapboxNavigation#startNavigation on a successful
  17. }
  18. });
  19. // ... (other code)
  20. button.setOnClickListener(new View.OnClickListener() {
  21. @Override
  22. public void onClick(View v) {
  23. // From Mapbox to The White House
  24. Point origin = Point.fromLngLat(-38.62882018, -3.78666528);
  25. Point destination = Point.fromLngLat(-38.56038094, -3.7337361F);
  26. NavigationRoute.builder(mapbox.this)
  27. .accessToken(getString(R.string.mapbox_access_token))
  28. .origin(origin)
  29. .destination(destination)
  30. .build()
  31. .getRoute(new Callback<DirectionsResponse>() {
  32. @Override
  33. public void onResponse(Call<DirectionsResponse> call, Response<DirectionsResponse> response) {
  34. Log.i(TAG, response+"");
  35. // Route fetched from NavigationRoute
  36. DirectionsRoute route = response.body().routes().get(0);
  37. // Create a NavigationLauncherOptions object to package everything together
  38. NavigationLauncherOptions options = NavigationLauncherOptions.builder()
  39. .directionsRoute(route)
  40. .shouldSimulateRoute(false)
  41. .build();
  42. // Call this method with Context from within an Activity
  43. NavigationLauncher.startNavigation(mapbox.this, options);
  44. }
  45. @Override
  46. public void onFailure(Call<DirectionsResponse> call, Throwable t) {
  47. // Handle failure
  48. }
  49. });
  50. }
  51. });
  52. // ... (other lifecycle methods)
  53. }
  54. // ... (other methods and lifecycle overrides)
  55. }
英文:

I'm actually trying to use the useroffroute function but it's not working, I saw this other post and it said to NavigationView, only I don't know how to do it exactly. I am currently using this code to detect if the user has left the route, but he is not calling the useroffroute function. What I'm trying to do is that when the user leaves the route he fires a Toast for the user, but unfortunately I was not successful.

  1. public class mapbox extends AppCompatActivity{
  2. private MapView mapView;
  3. Button button;
  4. private static final String TAG = &quot;resultados&quot;;
  5. private MapboxNavigation navigation;
  6. private boolean running;
  7. private NavigationMapboxMap map;
  8. @Override
  9. protected void onCreate(Bundle savedInstanceState) {
  10. super.onCreate(savedInstanceState);
  11. Mapbox.getInstance(this, getString(R.string.mapbox_access_token));
  12. setContentView(R.layout.activity_mapbox);
  13. button = findViewById(R.id.button);
  14. MapboxNavigationOptions options = MapboxNavigationOptions.builder().isDebugLoggingEnabled(true).build();
  15. navigation = new MapboxNavigation(getApplicationContext(), getString(R.string.mapbox_access_token), options);
  16. /*
  17. navigation.addOffRouteListener(new OffRouteListener() {
  18. @Override
  19. public void userOffRoute(Location location) {
  20. Toast.makeText(getApplicationContext(), &quot;Off route detected.........&quot;, Toast.LENGTH_SHORT).show();
  21. // Make sure you call for a new DirectionsRoute object
  22. // and end by calling MapboxNavigation#startNavigation on a successful
  23. }
  24. });
  25. */
  26. /*
  27. mapView = (MapView) findViewById(R.id.mapView);
  28. mapView.onCreate(savedInstanceState);
  29. mapView.getMapAsync(new OnMapReadyCallback() {
  30. @Override
  31. public void onMapReady(@NonNull MapboxMap mapboxMap) {
  32. mapboxMap.setStyle(Style.MAPBOX_STREETS, new Style.OnStyleLoaded() {
  33. @Override
  34. public void onStyleLoaded(@NonNull Style style) {
  35. // Map is set up and the style has loaded. Now you can add data or make other map adjustments
  36. }
  37. });
  38. }
  39. });
  40. */
  41. button.setOnClickListener(new View.OnClickListener() {
  42. @Override
  43. public void onClick(View v) {
  44. // From Mapbox to The White House
  45. Point origin = Point.fromLngLat(-38.62882018, -3.78666528);
  46. Point destination = Point.fromLngLat(-38.56038094, -3.7337361F);
  47. NavigationRoute.builder(mapbox.this)
  48. .accessToken(getString(R.string.mapbox_access_token))
  49. .origin(origin)
  50. .destination(destination)
  51. .build()
  52. .getRoute(new Callback&lt;DirectionsResponse&gt;() {
  53. @Override
  54. public void onResponse(Call&lt;DirectionsResponse&gt; call, Response&lt;DirectionsResponse&gt; response) {
  55. Log.i(TAG, response+&quot;&quot;);
  56. // Route fetched from NavigationRoute
  57. DirectionsRoute route = response.body().routes().get(0);
  58. // Create a NavigationLauncherOptions object to package everything together
  59. NavigationLauncherOptions options = NavigationLauncherOptions.builder()
  60. .directionsRoute(route)
  61. .shouldSimulateRoute(false)
  62. .build();
  63. // Call this method with Context from within an Activity
  64. NavigationLauncher.startNavigation(mapbox.this, options);
  65. }
  66. @Override
  67. public void onFailure(Call&lt;DirectionsResponse&gt; call, Throwable t) {
  68. }
  69. });
  70. }
  71. });
  72. }
  73. @Override
  74. protected void onStart() {
  75. super.onStart();
  76. //mapView.onStart();
  77. }
  78. @Override
  79. protected void onResume() {
  80. super.onResume();
  81. //mapView.onResume();
  82. }
  83. @Override
  84. protected void onPause() {
  85. super.onPause();
  86. //mapView.onPause();
  87. }
  88. @Override
  89. protected void onStop() {
  90. super.onStop();
  91. //mapView.onStop();
  92. }
  93. @Override
  94. public void onSaveInstanceState(@NonNull Bundle outState, @NonNull PersistableBundle outPersistentState) {
  95. super.onSaveInstanceState(outState, outPersistentState);
  96. //mapView.onSaveInstanceState(outState);
  97. }
  98. @Override
  99. public void onLowMemory() {
  100. super.onLowMemory();
  101. //mapView.onLowMemory();
  102. }
  103. @Override
  104. protected void onDestroy() {
  105. super.onDestroy();
  106. //mapView.onDestroy();
  107. }
  108. }

答案1

得分: 1

以下是翻译好的部分:

  1. public class last extends AppCompatActivity implements OnNavigationReadyCallback,
  2. NavigationListener, RouteListener, ProgressChangeListener {
  3. private NavigationView navigationView;
  4. private boolean dropoffDialogShown;
  5. private Location lastKnownLocation;
  6. private List<Point> points = new ArrayList<>();
  7. @Override
  8. protected void onCreate(@Nullable Bundle savedInstanceState) {
  9. Mapbox.getInstance(this, getString(R.string.mapbox_access_token));
  10. setTheme(R.style.Theme_AppCompat_NoActionBar);
  11. super.onCreate(savedInstanceState);
  12. points.add(Point.fromLngLat(-38.62882018, -3.78666528));
  13. points.add(Point.fromLngLat(-38.56038094, -3.7337361));
  14. setContentView(R.layout.activity_last);
  15. navigationView = findViewById(R.id.navigationView);
  16. navigationView.onCreate(savedInstanceState);
  17. navigationView.initialize(this);
  18. }
  19. @Override
  20. public void onStart() {
  21. super.onStart();
  22. navigationView.onStart();
  23. }
  24. // 更多的生命周期回调...
  25. @Override
  26. public void onNavigationReady(boolean isRunning) {
  27. fetchRoute(points.remove(0), points.remove(0));
  28. }
  29. // 更多的回调方法...
  30. @Override
  31. public void onArrival() {
  32. if (!dropoffDialogShown && !points.isEmpty()) {
  33. showDropoffDialog();
  34. dropoffDialogShown = true;
  35. Toast.makeText(this, "You have arrived!", Toast.LENGTH_SHORT).show();
  36. }
  37. }
  38. @Override
  39. public void onProgressChange(Location location, RouteProgress routeProgress) {
  40. lastKnownLocation = location;
  41. }
  42. private void startNavigation(DirectionsRoute directionsRoute) {
  43. NavigationViewOptions navigationViewOptions = setupOptions(directionsRoute);
  44. navigationView.startNavigation(navigationViewOptions);
  45. }
  46. private void showDropoffDialog() {
  47. AlertDialog alertDialog = new AlertDialog.Builder(this).create();
  48. alertDialog.setMessage(getString(R.string.dropoff_dialog_text));
  49. alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, getString(R.string.dropoff_dialog_positive_text),
  50. (dialogInterface, in) -> fetchRoute(getLastKnownLocation(), points.remove(0)));
  51. alertDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.dropoff_dialog_negative_text),
  52. (dialogInterface, in) -> {
  53. // Do nothing
  54. });
  55. alertDialog.show();
  56. }
  57. private void fetchRoute(Point origin, Point destination) {
  58. NavigationRoute.builder(this)
  59. .accessToken(Mapbox.getAccessToken())
  60. .origin(origin)
  61. .destination(destination)
  62. .alternatives(true)
  63. .build()
  64. .getRoute(new Callback<DirectionsResponse>() {
  65. @Override
  66. public void onResponse(Call<DirectionsResponse> call, Response<DirectionsResponse> response) {
  67. DirectionsResponse directionsResponse = response.body();
  68. if (directionsResponse != null && !directionsResponse.routes().isEmpty()) {
  69. startNavigation(directionsResponse.routes().get(0));
  70. }
  71. }
  72. @Override
  73. public void onFailure(Call<DirectionsResponse> call, Throwable t) {
  74. // Handle failure
  75. }
  76. });
  77. }
  78. // 更多的方法...
  79. }
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <androidx.constraintlayout.widget.ConstraintLayout
  3. xmlns:android="http://schemas.android.com/apk/res/android"
  4. xmlns:app="http://schemas.android.com/apk/res-auto"
  5. android:layout_width="match_parent"
  6. android:layout_height="match_parent">
  7. <com.mapbox.services.android.navigation.ui.v5.NavigationView
  8. android:id="@+id/navigationView"
  9. android:layout_width="0dp"
  10. android:layout_height="0dp"
  11. app:navigationLightTheme="@style/NavigationViewLight"
  12. app:navigationDarkTheme="@style/NavigationViewDark"
  13. app:layout_constraintBottom_toBottomOf="parent"
  14. app:layout_constraintEnd_toEndOf="parent"
  15. app:layout_constraintStart_toStartOf="parent"
  16. app:layout_constraintTop_toTopOf="parent"/>
  17. </androidx.constraintlayout.widget.ConstraintLayout>
英文:

After many hours looking for a solution, I finally found one. You have to use NavigationViewer to obtain the parameters that the application passes, so you can listen if the user leaves the route. Here's an example:

  1. public class last extends AppCompatActivity implements OnNavigationReadyCallback,
  2. NavigationListener, RouteListener, ProgressChangeListener {
  3. private NavigationView navigationView;
  4. private boolean dropoffDialogShown;
  5. private Location lastKnownLocation;
  6. private List&lt;Point&gt; points = new ArrayList&lt;&gt;();
  7. @Override
  8. protected void onCreate(@Nullable Bundle savedInstanceState) {
  9. Mapbox.getInstance(this, getString(R.string.mapbox_access_token));
  10. setTheme(R.style.Theme_AppCompat_NoActionBar);
  11. super.onCreate(savedInstanceState);
  12. points.add(Point.fromLngLat(-38.62882018, -3.78666528));
  13. points.add(Point.fromLngLat(-38.56038094, -3.7337361));
  14. setContentView(R.layout.activity_last);
  15. navigationView = findViewById(R.id.navigationView);
  16. navigationView.onCreate(savedInstanceState);
  17. navigationView.initialize(this);
  18. }
  19. @Override
  20. public void onStart() {
  21. super.onStart();
  22. navigationView.onStart();
  23. }
  24. @Override
  25. public void onResume() {
  26. super.onResume();
  27. navigationView.onResume();
  28. }
  29. @Override
  30. public void onLowMemory() {
  31. super.onLowMemory();
  32. navigationView.onLowMemory();
  33. }
  34. @Override
  35. public void onBackPressed() {
  36. // If the navigation view didn&#39;t need to do anything, call super
  37. if (!navigationView.onBackPressed()) {
  38. super.onBackPressed();
  39. }
  40. }
  41. @Override
  42. protected void onSaveInstanceState(Bundle outState) {
  43. navigationView.onSaveInstanceState(outState);
  44. super.onSaveInstanceState(outState);
  45. }
  46. @Override
  47. protected void onRestoreInstanceState(Bundle savedInstanceState) {
  48. super.onRestoreInstanceState(savedInstanceState);
  49. navigationView.onRestoreInstanceState(savedInstanceState);
  50. }
  51. @Override
  52. public void onPause() {
  53. super.onPause();
  54. navigationView.onPause();
  55. }
  56. @Override
  57. public void onStop() {
  58. super.onStop();
  59. navigationView.onStop();
  60. }
  61. @Override
  62. protected void onDestroy() {
  63. super.onDestroy();
  64. navigationView.onDestroy();
  65. }
  66. @Override
  67. public void onNavigationReady(boolean isRunning) {
  68. fetchRoute(points.remove(0), points.remove(0));
  69. }
  70. @Override
  71. public void onCancelNavigation() {
  72. // Navigation canceled, finish the activity
  73. finish();
  74. }
  75. @Override
  76. public void onNavigationFinished() {
  77. // Intentionally empty
  78. }
  79. @Override
  80. public void onNavigationRunning() {
  81. // Intentionally empty
  82. }
  83. @Override
  84. public boolean allowRerouteFrom(Point offRoutePoint) {
  85. return true;
  86. }
  87. @Override
  88. public void onOffRoute(Point offRoutePoint) {
  89. Toast.makeText(this, &quot;Off route&quot;, Toast.LENGTH_SHORT).show();
  90. }
  91. @Override
  92. public void onRerouteAlong(DirectionsRoute directionsRoute) {
  93. }
  94. @Override
  95. public void onFailedReroute(String errorMessage) {
  96. }
  97. @Override
  98. public void onArrival() {
  99. if (!dropoffDialogShown &amp;&amp; !points.isEmpty()) {
  100. showDropoffDialog();
  101. dropoffDialogShown = true; // Accounts for multiple arrival events
  102. Toast.makeText(this, &quot;You have arrived!&quot;, Toast.LENGTH_SHORT).show();
  103. }
  104. }
  105. @Override
  106. public void onProgressChange(Location location, RouteProgress routeProgress) {
  107. lastKnownLocation = location;
  108. }
  109. private void startNavigation(DirectionsRoute directionsRoute) {
  110. NavigationViewOptions navigationViewOptions = setupOptions(directionsRoute);
  111. navigationView.startNavigation(navigationViewOptions);
  112. }
  113. private void showDropoffDialog() {
  114. AlertDialog alertDialog = new AlertDialog.Builder(this).create();
  115. alertDialog.setMessage(getString(R.string.dropoff_dialog_text));
  116. alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, getString(R.string.dropoff_dialog_positive_text),
  117. (dialogInterface, in) -&gt; fetchRoute(getLastKnownLocation(), points.remove(0)));
  118. alertDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.dropoff_dialog_negative_text),
  119. (dialogInterface, in) -&gt; {
  120. // Do nothing
  121. });
  122. alertDialog.show();
  123. }
  124. private void fetchRoute(Point origin, Point destination) {
  125. NavigationRoute.builder(this)
  126. .accessToken(Mapbox.getAccessToken())
  127. .origin(origin)
  128. .destination(destination)
  129. .alternatives(true)
  130. .build()
  131. .getRoute(new Callback&lt;DirectionsResponse&gt;() {
  132. @Override
  133. public void onResponse(Call&lt;DirectionsResponse&gt; call, Response&lt;DirectionsResponse&gt; response) {
  134. DirectionsResponse directionsResponse = response.body();
  135. if (directionsResponse != null &amp;&amp; !directionsResponse.routes().isEmpty()) {
  136. startNavigation(directionsResponse.routes().get(0));
  137. }
  138. }
  139. @Override
  140. public void onFailure(Call&lt;DirectionsResponse&gt; call, Throwable t) {
  141. }
  142. });
  143. }
  144. private NavigationViewOptions setupOptions(DirectionsRoute directionsRoute) {
  145. dropoffDialogShown = false;
  146. NavigationViewOptions.Builder options = NavigationViewOptions.builder();
  147. options.directionsRoute(directionsRoute)
  148. .navigationListener(this)
  149. .progressChangeListener(this)
  150. .routeListener(this)
  151. .shouldSimulateRoute(false);
  152. return options.build();
  153. }
  154. private Point getLastKnownLocation() {
  155. return Point.fromLngLat(lastKnownLocation.getLongitude(), lastKnownLocation.getLatitude());
  156. }

}

XML File:

  1. &lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  2. &lt;androidx.constraintlayout.widget.ConstraintLayout
  3. xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
  4. xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
  5. android:layout_width=&quot;match_parent&quot;
  6. android:layout_height=&quot;match_parent&quot;&gt;
  7. &lt;com.mapbox.services.android.navigation.ui.v5.NavigationView
  8. android:id=&quot;@+id/navigationView&quot;
  9. android:layout_width=&quot;0dp&quot;
  10. android:layout_height=&quot;0dp&quot;
  11. app:navigationLightTheme=&quot;@style/NavigationViewLight&quot;
  12. app:navigationDarkTheme=&quot;@style/NavigationViewDark&quot;
  13. app:layout_constraintBottom_toBottomOf=&quot;parent&quot;
  14. app:layout_constraintEnd_toEndOf=&quot;parent&quot;
  15. app:layout_constraintStart_toStartOf=&quot;parent&quot;
  16. app:layout_constraintTop_toTopOf=&quot;parent&quot;/&gt;
  17. &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;

答案2

得分: 0

  1. 当我开始使用多个途径点进行导航时导航在达到第一个途径点后停止
  2. 请提供建议更改
  3. try {
  4. NavigationRoute.Builder builder = NavigationRoute.builder(this)
  5. .accessToken("pk." + getString(R.string.gh_key))
  6. .baseUrl(getString(R.string.base_url))
  7. .user("gh")
  8. .alternatives(true);
  9. Location lastKnownLocation = new Location(LocationManager.GPS_PROVIDER);
  10. lastKnownLocation.setLatitude(Double.parseDouble(SharePref.getInstance(MapBoxNavActivity.this).getJavaRXPref(getString(R.string.latitude))));
  11. lastKnownLocation.setLongitude(Double.parseDouble(SharePref.getInstance(MapBoxNavActivity.this).getJavaRXPref(getString(R.string.longitude))));
  12. Point location = Point.fromLngLat(lastKnownLocation.getLongitude(), lastKnownLocation.getLatitude());
  13. if (lastKnownLocation.hasBearing()) {
  14. // 90 seems to be the default tolerance of the SDK
  15. builder.origin(location, (double) lastKnownLocation.getBearing(), 90.0);
  16. } else {
  17. builder.origin(location);
  18. }
  19. try {
  20. if (waypoints.size() > 0) {
  21. for (int i = 0; i < waypoints.size(); i++) {
  22. Point p = waypoints.get(i);
  23. if (i < waypoints.size() - 1) {
  24. try {
  25. builder.addWaypoint(p);
  26. } catch (Exception e) {
  27. e.printStackTrace();
  28. }
  29. } else {
  30. builder.destination(p);
  31. }
  32. }
  33. }
  34. } catch (Exception se) {
  35. se.printStackTrace();
  36. }
  37. builder.build().getRoute(new SimplifiedCallback() {
  38. @Override
  39. public void onResponse(Call<DirectionsResponse> call, Response<DirectionsResponse> response) {
  40. if (validRouteResponse(response)) {
  41. route = response.body().routes().get(0);
  42. try {
  43. MapboxNavigationOptions.Builder navigationOptions = MapboxNavigationOptions.builder();
  44. NavigationViewOptions.Builder options = NavigationViewOptions.builder();
  45. options.navigationListener(MapBoxNavActivity.this);
  46. options.directionsRoute(route);
  47. options.shouldSimulateRoute(false);
  48. options.directionsProfile(DirectionsCriteria.PROFILE_DRIVING_TRAFFIC);
  49. navigationOptions.enableOffRouteDetection(true);
  50. navigationOptions.snapToRoute(true);
  51. options.navigationOptions(navigationOptions.build());
  52. navigationView.startNavigation(options.build());
  53. } catch (Exception e) {
  54. e.printStackTrace();
  55. }
  56. }
  57. }
  58. @Override
  59. public void onFailure(Call<DirectionsResponse> call, Throwable throwable) {
  60. super.onFailure(call, throwable);
  61. Log.i("Fetch route error", throwable.getMessage());
  62. }
  63. });
  64. } catch (Exception se) {
  65. se.printStackTrace();
  66. }
英文:

When I start navigation with multiple waypoints, the navigation stops after reaching first waypoint.
Please suggest changes.`

  1. try{
  2. NavigationRoute.Builder builder = NavigationRoute.builder(this)
  3. .accessToken(&quot;pk.&quot; + getString(R.string.gh_key))
  4. .baseUrl(getString(R.string.base_url))
  5. .user(&quot;gh&quot;)
  6. .alternatives(true);
  7. Location lastKnownLocation = new Location(LocationManager.GPS_PROVIDER);
  8. lastKnownLocation.setLatitude(Double.parseDouble(SharePref.getInstance(MapBoxNavActivity.this).getJavaRXPref(getString(R.string.latitude))));
  9. lastKnownLocation.setLongitude(Double.parseDouble(SharePref.getInstance(MapBoxNavActivity.this).getJavaRXPref(getString(R.string.longitude))));
  10. Point location = Point.fromLngLat(lastKnownLocation.getLongitude(), lastKnownLocation.getLatitude());
  11. if (lastKnownLocation.hasBearing()){
  12. // 90 seems to be the default tolerance of the SDK
  13. builder.origin(location, (double) lastKnownLocation.getBearing(), 90.0);
  14. }
  15. else{
  16. builder.origin(location);
  17. }
  18. try {
  19. if(waypoints.size()&gt;0){
  20. for (int i = 0; i &lt; waypoints.size(); i++) {
  21. Point p = waypoints.get(i);
  22. if (i &lt; waypoints.size() - 1) {
  23. try {
  24. builder.addWaypoint(p);
  25. }catch (Exception e){
  26. e.printStackTrace();
  27. }
  28. } else {
  29. builder.destination(p);
  30. }
  31. }
  32. }
  33. }catch (Exception se){
  34. se.printStackTrace();
  35. }
  36. builder.build().getRoute(new SimplifiedCallback() {
  37. @Override
  38. public void onResponse(Call&lt;DirectionsResponse&gt; call, Response&lt;DirectionsResponse&gt; response) {
  39. if (validRouteResponse(response)) {
  40. route = response.body().routes().get(0);
  41. try {
  42. MapboxNavigationOptions.Builder navigationOptions = MapboxNavigationOptions.builder();
  43. NavigationViewOptions.Builder options = NavigationViewOptions.builder();
  44. options.navigationListener(MapBoxNavActivity.this);
  45. options.directionsRoute(route);
  46. options.shouldSimulateRoute(false);
  47. options.directionsProfile(DirectionsCriteria.PROFILE_DRIVING_TRAFFIC);
  48. navigationOptions.enableOffRouteDetection(true);
  49. navigationOptions.snapToRoute(true);
  50. options.navigationOptions(navigationOptions.build());
  51. navigationView.startNavigation(options.build());
  52. }catch (Exception e){
  53. e.printStackTrace();
  54. }
  55. }
  56. }
  57. @Override
  58. public void onFailure(Call&lt;DirectionsResponse&gt; call, Throwable throwable) {
  59. super.onFailure(call, throwable);
  60. Log.i(&quot;Fetch route error&quot;,throwable.getMessage());
  61. }
  62. });
  63. }
  64. }
  65. catch ( Exception se){
  66. se.printStackTrace();
  67. }
  68. }

`

huangapple
  • 本文由 发表于 2020年4月10日 21:44:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/61141587.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定