Skobbler返回空的建议列表

时间:2015-10-09 12:50:46

标签: android skmaps

在Skobbler路线计算中,我只获得路线坐标列表。

代码,

private void launchRouteCalculation(SKCoordinate startPoint, SKCoordinate destinationPoint) {
    SKRouteManager.getInstance().clearAllRoutesFromCache();
    // get a route object and populate it with the desired properties
    SKRouteSettings route = new SKRouteSettings();
    route.setStartCoordinate(startPoint);
    route.setRequestAdvices(true);
    route.setDestinationCoordinate(destinationPoint);
    route.setNoOfRoutes(1);
    route.setRouteMode(SKRouteSettings.SKRouteMode.CAR_FASTEST);
    route.setRouteExposed(true);
    SKRouteManager.getInstance().setRouteListener(this);
    SKRouteManager.getInstance().calculateRoute(route);
}

onRouteCalculationCompletedonAllRoutesCompleted中,我试图获取建议列表。但它始终返回null

此外,在开始导航时,我在SKNavigationState方法中未获得正确的onUpdateNavigationState。请帮助。

1 个答案:

答案 0 :(得分:0)

这是我的工作代码,用于获取建议列表。 第一步 - 开始路线计算:

SKRouteSettings route = new SKRouteSettings();
route.setStartCoordinate(startLoc);
route.setDestinationCoordinate(destinationLoc);
route.setNoOfRoutes(3);
route.setExtendedPointsReturned(true);
route.setRequestAdvices(true);
route.setRouteMode(SKRouteSettings.SKRouteMode.CAR_FASTEST);
route.setRouteExposed(true);
route.setRequestAdvices(true);
rm.setRouteListener(this);
final SKAdvisorSettings advisorSettings = new SKAdvisorSettings();
advisorSettings.setLanguage(SKAdvisorSettings.SKAdvisorLanguage.LANGUAGE_RU);
advisorSettings.setAdvisorConfigPath(activity.getFilesDir() + "/SKMaps/Advisor");
advisorSettings.setResourcePath(activity.getFilesDir() + "/SKMaps/Advisor/Languages");
advisorSettings.setAdvisorVoice("ru");
advisorSettings.setAdvisorType(SKAdvisorSettings.SKAdvisorType.AUDIO_FILES);
rm.setAudioAdvisorSettings(advisorSettings);
rm.calculateRoute(route);

第二步 - 当路线计算成功时,请求获取建议清单:

//better execute this code in background thread
List<RoutePoint> points = new ArrayList<RoutePoint>();
SKRouteManager rm = SKRouteManager.getInstance();
int id = data.routesInfo.get(currentRouteIndex).id; //because i set 3 routes in calculation step and use ui selection of routes. "currentRouteIndex" should be 0, 1 or 2
List<SKRouteAdvice> ri = rm.getAdviceList(id, SKMaps.SKDistanceUnitType.DISTANCE_UNIT_KILOMETER_METERS);
for (SKRouteAdvice aRi : ri) {
    RoutePoint point = new RoutePoint(); // my custom advice class object, use class what you need or just save list of SKRouteAdvice items
    point.distanceMeters = aRi.getDistanceToAdvice();
    point.instruction = aRi.getAdviceInstruction();
    point.street = aRi.getStreetName();
    point.image_path = aRi.getVisualAdviceFile();
    point.durationSec = aRi.getTimeToAdvice();
    point.id = aRi.getAdviceID();
    points.add(point);
}
data.routePoints = points;