Mot*_*o28 1 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) {
}
});
Run Code Online (Sandbox Code Playgroud)
但是,该应用程序要求某些查询添加了多个航路点。经过大量搜索,我发现这个mapbox-navigation-android 添加了导致以下代码的航点。但是,查询永远不会返回响应。
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) {
}
});
Run Code Online (Sandbox Code Playgroud)
关于为什么我没有得到回应的任何想法都会很棒。
默认配置文件PROFILE_DRIVING_TRAFFIC限制为 3 个坐标。如果您将其更新为PROFILE_DRIVING,使用.profile(DirectionsCriteria.PROFILE_DRIVING),那应该可以解决坐标限制问题。
| 归档时间: |
|
| 查看次数: |
708 次 |
| 最近记录: |