尝试在我的android项目中实现MapBox导航路线叠加层。我将遵循一个由四个部分组成的系列。我在NavigationRoute.builder()
上看到错误消息
builder
(Context)
in NavigationRoute cannot be applied
to
()
该教程有点旧,所以我不确定是否是这个原因,但我对此表示怀疑。
以下是变量:
private NavigationMapRoute navigationMapRoute;
这是完整的方法:
private void getRoute(Point origin, Point destination){
NavigationRoute.builder().accessToken(Mapbox.getAccessToken()).origin(origin).destination(destination).build().getRoute(new Callback<DirectionsResponse>() {
@Override
public void onResponse(Call<DirectionsResponse> call, Response<DirectionsResponse> response) {
if (response.body() == null){
Log.e(TAG, "No route found, check user access token");
return;
}else{
if (response.body().routes().size() == 0){
Log.e(TAG, "No route found, check user access token");
return;
}
DirectionsRoute currentRoute = response.body().routes().get(0);
if (navigationMapRoute != null){
navigationMapRoute.removeRoute();
}else{
navigationMapRoute = new NavigationMapRoute(null, mapView, map);
navigationMapRoute.addRoute(currentRoute);
}
}
}
@Override
public void onFailure(Call<DirectionsResponse> call, Throwable t) {
Log.e (TAG, "Error:" + t.getMessage());
}
});
}
我也收到Log.e
的警告,说我宁可使用Timber
,对此我也不熟悉。
谢谢