Electric Bike Routing
Overview
Starting with Navigation SDK v8.0.0, electric bike route planning and navigation are fully supported. To use this feature, you must work with the AMapNaviEleBikeManager class.
Important: Electric bike route planning is a paid service. Whether you are requesting a trial or applying for production use, please submit a business cooperation ticket through the ticket system. Otherwise, route calculation will fail by default.
To implement electric bike route planning, you need to understand the following three classes:
- AMapNaviEleBikeManager — The electric bike navigation manager class. It provides methods for route planning, pre-trip route selection, and rerouting during navigation.
Note: Starting with Navigation SDK v8.0.0, the init method of AMapNaviEleBikeManager is deprecated. Use the singleton [AMapNaviEleBikeManager sharedInstance] instead. When the class's dealloc function is called, or at an appropriate time (such as when the navigation view controller is popped), call [AMapNaviEleBikeManager destroyInstance] to destroy the singleton. If the singleton is not destroyed successfully, check whether it is strongly referenced.
- <AMapNaviEleBikeManagerDelegate> — The electric bike navigation manager delegate protocol. It provides callback interfaces for events during route calculation and navigation, such as route planning success/failure, TTS strings, weak GPS signal, and arrival at the destination.
- <AMapNaviEleBikeDataRepresentable> — The electric bike navigation data protocol. It provides callback interfaces for real-time data during route calculation and navigation, such as guidance information (NaviInfo) and positioning information.
Notes
- Route planning requires a network connection.
- You can obtain the start and end points in several ways, for example:
- Use the coordinate picker to query the coordinates of a desired point.
- Use the POI search in the Search SDK to find points of interest as start or end points.
- Three methods are available for electric bike route planning, as shown in the table below:
Recommendation: Use the -calculateEleBikeRouteWithStartPOIInfo:endPOIInfo:strategy: method for route planning. The SDK automatically completes other information based on the POIId or startPOIInfo.startAngle, resulting in a more reasonable route and reducing detours.
Usage
Step 1: Set the Start and End Points
// Initialize start and end points using POI
self.startPOIInfo = [[AMapNaviPOIInfo alloc] init];
self.startPOIInfo.mid = @"B0FFFAB6J2";
self.endPOIInfo = [[AMapNaviPOIInfo alloc] init];
self.endPOIInfo.mid = @"B0FFIA9OE8";Step 2: Calculate the Route
// Calculate the electric bike route using POI
[[AMapNaviEleBikeManager sharedInstance] calculateEleBikeRouteWithStartPOIInfo:self.startPOIInfo
endPOIInfo:self.endPOIInfo
strategy:AMapNaviTravelStrategyMultipleDefault];Step 3: Handle the Result
When the electric bike route calculation succeeds, the -rideManagerOnCalculateRouteSuccess: callback is triggered. In this callback, you can display the planned route or start navigation directly.
- (void)rideManagerOnCalculateRouteSuccess:(AMapNaviRideManager *)rideManager
{
NSLog(@"onCalculateRouteSuccess");
// Display the route or start navigation
}