0

I'm trying to put some waypoints on the Navigation UI but I have the issue of the title, here's my code, in the foreach is where I have the problem. It seems like I didn't import something

Point[] waypoints = {Point.fromLngLat(2.444740599999932, 41.5381124),Point.fromLngLat(2.407215469098446, 41.520481047202615};

      @Override
public void onNavigationReady() {
    NavigationViewOptions.Builder options = NavigationViewOptions.builder();
    options.navigationListener(this);
    options.origin(origin);
    options.destination(destination);
    options.shouldSimulateRoute(true);
    options.progressChangeListener(this);

    for (Point waypoint : waypoints) {
        options.addWaypoint(waypoint);
    }

    navigationView.startNavigation(options.build());
}
  • Could you please explain more precisely what the issue with your title is? – Nathan Apr 19 '18 at 08:48
  • @Nathan I just can't use the function, as if I hadn't imported something –  Apr 19 '18 at 09:00
  • Do you miss anything on this?. Because "addWayPoint" is a method in NavigationRoute.Builder not NavigationViewOptions.Builder like you use. – Son Truong Apr 19 '18 at 09:13
  • @sontruongit So I should use navigation UI using NavigationRoute.Builder? –  Apr 19 '18 at 09:27
  • @Lluís yeah based on your requirement. You can take a look example code here: https://www.mapbox.com/help/android-navigation-sdk/ – Son Truong Apr 19 '18 at 09:30
  • @sontruongit I'll look again, thanks! –  Apr 19 '18 at 09:36

1 Answers1

1

addWayPoint is a method from NavigationRoute.Builder not NavigationViewOptions.Builder. That why the IDE cannot resolve it.

From your code I guess you want to draw or simulate a navigation route (origin, destination, all points on route, etc..).

Please take a look examples at below official site how to use NavigationRoute.Builder API.

https://www.mapbox.com/help/android-navigation-sdk/

Son Truong
  • 13,661
  • 5
  • 32
  • 58