Mapbox导航启动器添加航点名称

时间:2018-07-27 09:04:09

标签: android mapbox

我们正在使用Mapbox导航启动器创建导航,在添加航路点名称之前,它一直工作正常。添加航路点后,名称应用程序开始随机崩溃(有时在第一个航路点,有时在另一路途)。每次erorr都相同时,“航路点名称的数量必须与提供的航路点的数量匹配”

这是我们的代码:

     List<TourDetailResponse.TourDetailsPoi> pois = tourDetailResponse.getPois();

    Point origin = Point.fromLngLat(currentLongitude, currentLatitude);

    Point destination = Point.fromLngLat(pois.get(pois.size()-1).getLongitude(), pois.get(pois.size()-1).getLatitude());

    NavigationRoute.Builder  builder = NavigationRoute.builder(coreActivity)
            .accessToken(Mapbox.getAccessToken())
            .origin(origin)
            .destination(destination)


    .profile(DirectionsCriteria.PROFILE_WALKING);


    StringBuilder sb = new StringBuilder();


    sb.append("origin##");

        for(int q=0;q<pois.size()-1;q++)
    {
        Point point = Point.fromLngLat(pois.get(q).getLongitude(), pois.get(q).getLatitude());

        builder.addWaypoint(point);
        sb.append(pois.get(q).getName()+"##");
    }

    builder.language(Locale.getDefault());

    sb.append(pois.get(pois.size()-1).getName()+"##");

    sb.setLength(sb.length()-2);

    try
    {
       builder.addWaypointNames(sb.toString().split("##"));
    }catch (Exception e)
    {
        e.printStackTrace();
    }

在调试模式下,我们检查了航路点名称的数量与航路点的数量

  

堆栈跟踪:致命异常:   com.mapbox.core.exceptions.ServicesException:航点名称的数量   必须与提供的航点数量相匹配。          在com.mapbox.api.directions.v5.MapboxDirections $ Builder.build(MapboxDirections.java:757)          在com.mapbox.services.android.navigation.v5.navigation.NavigationRoute $ Builder.build(NavigationRoute.java:558)处          在com.mapbox.services.android.navigation.v5.route.RouteFetcher.executeRouteCall(RouteFetcher.java:120)          在com.mapbox.services.android.navigation.v5.route.RouteFetcher.findRouteFromRouteProgress(RouteFetcher.java:72)          在com.mapbox.services.android.navigation.ui.v5.route.ViewRouteFetcher.fetchRouteFromOffRouteEvent(ViewRouteFetcher.java:65)          在com.mapbox.services.android.navigation.ui.v5.NavigationViewModel.sendEventOffRoute(NavigationViewModel.java:410)          在com.mapbox.services.android.navigation.ui.v5.NavigationViewModel.access $ 600(NavigationViewModel.java:47)          在com.mapbox.services.android.navigation.ui.v5.NavigationViewModel $ 2.userOffRoute(NavigationViewModel.java:274)          在com.mapbox.services.android.navigation.v5.navigation.NavigationEventDispatcher.onUserOffRoute(NavigationEventDispatcher.java:150)          在com.mapbox.services.android.navigation.v5.navigation.RouteProcessorThreadListener.onUserOffRoute(RouteProcessorThreadListener.java:57)          在com.mapbox.services.android.navigation.v5.navigation.RouteProcessorHandlerCallback $ 1.run(RouteProcessorHandlerCallback.java:99)          在android.os.Handler.handleCallback(Handler.java:751)          在android.os.Handler.dispatchMessage(Handler.java:95)          在android.os.Looper.loop(Looper.java:154)          在android.app.ActivityThread.main(ActivityThread.java:6123)          在java.lang.reflect.Method.invoke(Method.java)          在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:867)          在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:757)

1 个答案:

答案 0 :(得分:0)

最后从地图箱中得到了答复,这是他们这边的错误。

https://github.com/mapbox/mapbox-navigation-android/issues/1160