Document Navigation SDK for Android Guides Route Planning Motorcycle Routing

Motorcycle Routing

The key difference from car navigation is that the motorcycle route planning strategy incorporates vehicle-specific information such as the license plate number and engine displacement into the route calculation.

Important: Motorcycle route planning is a paid feature. Whether you are requesting a trial or planning for production use, please submit a business cooperation ticket through the ticket system to discuss your requirements. Otherwise, route calculation will fail by default.

The route calculation interface for motorcycles is identical to that for cars. The SDK distinguishes between vehicle types using vehicle information. When the CarType of AMapCarInfo is set to 11, it indicates a motorcycle.

Set Vehicle Information

Before performing route calculation, you must set the vehicle information. Otherwise, the settings will not take effect until the next route calculation.

// Build vehicle information
AMapCarInfo carInfo = new AMapCarInfo();
carInfo.setCarNumber("京C123456");   // Set license plate number
carInfo.setCarType("11");            // Set vehicle type, 11 represents motorcycle
carInfo.setMotorcycleCC(100);        // Set motorcycle engine displacement (cc)

AMapNavi mAMapNavi = AMapNavi.getInstance(this);
// Set vehicle information
mAMapNavi.setCarInfo(carInfo);

Handle Route Calculation Results

Route Calculation Success

When route calculation succeeds, the onCalculateRouteSuccess callback of AMapNaviListener is triggered. In this callback, you can retrieve the route object and display the planned route:

@Override
public void onCalculateRouteSuccess(AMapCalcRouteResult routeResult) {
    // Get route data objects
    HashMap<Integer, AMapNaviPath> naviPaths = AMapNavi.getInstance(this).getNaviPaths();
    // Draw and display the route
    ...
}

You can also start navigation directly:

@Override
public void onCalculateRouteSuccess(AMapCalcRouteResult routeResult) {
    // Start navigation
    AMapNavi.getInstance(this).startNavi(NaviType.GPS);
}

Route Calculation Failure

If route calculation fails, the onCalculateRouteFailure callback of AMapNaviListener is triggered. You can implement your error handling logic in this callback.