【发布时间】:2019-03-08 02:31:41
【问题描述】:
目前我正在尝试在 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) {
}
});
但是,应用程序要求某些查询添加多个航点。经过大量搜索后,我发现了这个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) {
}
});
任何关于为什么我没有得到回应的想法都会很棒。
【问题讨论】:
标签: android mapbox mapbox-android