gpt4 book ai didi

android - Mapbox Navigation SDK,将航路点添加到 NavigationRoute.builder() 时出现问题

转载 作者:行者123 更新时间:2023-11-29 16:31:22 27 4
gpt4 key购买 nike

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

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) {

}
});

但是,应用程序要求某些查询添加多个航路点。经过大量搜索,我找到了这个 mapbox-navigation-android add waypoints这导致下面的代码。但是,查询永远不会返回响应。

 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) {

}
});

任何关于为什么我没有收到回复的想法都很好。

最佳答案

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

关于android - Mapbox Navigation SDK,将航路点添加到 NavigationRoute.builder() 时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55023543/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com