Mapbox导航SDK,将航点添加到NavigationRoute.builder()时出现问题

时间:2019-03-06 12:50:05

标签: android mapbox mapbox-android

当前,我正在尝试在mapbox提供的android导航SDK中创建导航路线。当向查询添加多个航点时,问题开始。 (以下查询返回响应并在地图上绘制路线)

NavigationRoute.builder()
            .accessToken(Mapbox.getAccessToken())
            .origin(start)
            .destination(end)
            .alternatives(false)
            .build()
            .getRoute(new Callback<DirectionsResponse>() {
                @Override
                public void onResponse(@NonNull Call<DirectionsResponse> call, @NonNull Response<DirectionsResponse> response) {

                    if (response.isSuccessful()) {

                        try {
                            assert response.body() != null;
                            routeodfgoh = response.body().routes().get(0);

                            if (navigationMapRoute != null) {
                                navigationMapRoute.removeRoute();
                            } else {
                                navigationMapRoute = new NavigationMapRoute(null, mapView, map);
                            }

                            //how to draw the map think map matching is work
                            navigationMapRoute.addRoute(routeodfgoh);

                        } catch (Exception ex) {
                            Toast.makeText(MainActivity.this, ex.toString(), Toast.LENGTH_LONG);
                        }

                    }
                }

                @Override
                public void onFailure(Call<DirectionsResponse> call, Throwable t) {

                }
            });

但是,应用程序要求某些查询添加了多个航点。经过大量搜索后,我发现此enter image description here导致了以下代码。但是,查询从不返回响应。

 NavigationRoute.Builder builder = NavigationRoute.builder()
            .accessToken(Mapbox.getAccessToken())
            .origin(start)
            .destination(end);

    for (Point waypoint : coords) {
        builder.addWaypoint(waypoint);
    }

    builder.build()
            .getRoute(new Callback<DirectionsResponse>() {
        @Override
        public void onResponse(@NonNull Call<DirectionsResponse> call, @NonNull Response<DirectionsResponse> response) {

           if (response.isSuccessful()) {

                try {
                    assert response.body() != null;
                    routeodfgoh = response.body().routes().get(0);

                    if (navigationMapRoute != null) {
                        navigationMapRoute.removeRoute();
                    } else {
                        navigationMapRoute = new NavigationMapRoute(null, mapView, map);
                    }

                    //how to draw the map think map matching is work
                    navigationMapRoute.addRoute(routeodfgoh);

                } catch (Exception ex) {
                    Toast.makeText(MainActivity.this, ex.toString(), Toast.LENGTH_LONG);
                }

            }
        }

        @Override
        public void onFailure(Call<DirectionsResponse> call, Throwable t) {

        }
    });

关于我为什么没有得到答复的任何想法都是很棒的。

1 个答案:

答案 0 :(得分:3)

默认配置文件为PROFILE_DRIVING_TRAFFIC,其限制为3个坐标。如果使用PROFILE_DRIVING将其更新为.profile(DirectionsCriteria.PROFILE_DRIVING),那应该可以解决坐标限制问题。