0
我是Android和MapBox的新手,所以解決方案可能很明顯,我只是沒有看到它。MapBox SDK RouteLeg不包含任何信息
我正在嘗試爲Android使用MapBox實現轉彎轉向類型的應用程序。我已經能夠想出如何創建路線,在路線之後繪製多段線,並讓用戶沿着折線行進,並在用戶離開折線時重新路由。但是,由於某種原因,當我試圖從RouteLeg的RouteLeg中獲得下一個RouteStep時,RouteStep數組變爲空,我不知道爲什麼會發生這種情況。我已經發布了我在下面討論的代碼部分。
currentRoute = response.body().getRoutes().get(0);
Log.d(TAG, "Distance: " + currentRoute.getDistance());
Toast.makeText(
FollowRouteActivity.this,
"Route is " + currentRoute.getDistance() + " meters long.",
Toast.LENGTH_SHORT).show();
RouteLeg routeLeg = currentRoute.getLegs().get(0);
Log.d(TAG, "Next route leg distance: " + routeLeg.getDistance());
if (routeLeg.getSteps().size() > 0)
Log.d(TAG, "Next route step distance: " + routeLeg.getSteps().get(0).getDistance());
else
Log.d(TAG, "Next route step: No step found");
drawRoute(currentRoute);
此代碼片段始終顯示日誌中的「下一個路由步驟:找不到步驟」。
謝謝您的幫助!
還應該提到currentRoute.getDistance()返回正確的距離,並且當currentRoute傳遞給drawRoute()時,正在繪製多段線。 – user1467883