Android Mapbox导航SDK,向NavigationRoute.builder()添加航路点时出现问题
目前,我正在尝试在mapbox提供的android导航SDK中创建一条导航路线。将多个航路点添加到查询时,问题开始出现。下面的查询返回一个响应并在地图上绘制路线Android Mapbox导航SDK,向NavigationRoute.builder()添加航路点时出现问题,android,mapbox,mapbox-android,Android,Mapbox,Mapbox Android,目前,我正在尝试在mapbox提供的android导航SDK中创建一条导航路线。将多个航路点添加到查询时,问题开始出现。下面的查询返回一个响应并在地图上绘制路线 NavigationRoute.builder() .accessToken(Mapbox.getAccessToken()) .origin(start) .destination(end) .alternatives(false)
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) {
}
});
但是,应用程序要求某些查询添加多个航路点。经过大量的搜索,我找到了下面的代码。但是,查询从不返回响应
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\u DRIVING\u TRAFFIC,限制为3个坐标。如果使用.profileDirectionsCriteria.PROFILE\u DRIVING将此更新为PROFILE\u DRIVING,则应解决坐标限制问题。默认配置文件为PROFILE\u DRIVING\u TRAFFIC,其限制为3个坐标。如果您使用.profileDirectionsCriteria.PROFILE\u DRIVING将此更新为PROFILE\u DRIVING,则应该可以解决坐标限制问题。可丢弃显示我添加了太多坐标,根据可丢弃的值,允许的最大值为3。该文件称,最多可添加25个航路点,包括起点和终点。我用错这个类了吗?如果是这样的话,我需要做什么来创建一条有25个航路点的导航路线?可丢弃的显示我添加了太多的坐标,根据可丢弃的,允许的最大值是3。该文件称,最多可添加25个航路点,包括起点和终点。我用错这个类了吗?如果是,我需要做什么来创建一条有25个航路点的导航路线?