Walking Routing
Overview
To implement walking route planning, you need to understand the following three classes:
- AMapNaviWalkManager — The walking navigation management class. It provides methods for route planning, pre-trip route selection, and rerouting during navigation.
Important: Starting from Navigation SDK 7.4.0, the init method of AMapNaviWalkManager is deprecated. Use the singleton [AMapNaviWalkManager sharedInstance] instead. When the class is deallocated (for example, when the navigation view controller is popped), call [AMapNaviWalkManager destroyInstance] to destroy the singleton. If the singleton is not destroyed successfully, check whether it is strongly referenced.
- <AMapNaviWalkManagerDelegate> — The walking navigation management delegate protocol. It provides callbacks for events during route calculation and navigation, such as route calculation success/failure, TTS strings, weak GPS signal, and arrival at the destination.
- <AMapNaviWalkDataRepresentable> — The walking navigation data protocol. It provides callbacks for real-time data during route calculation and navigation, such as guidance information (NaviInfo) and positioning data.
Notes
- Route planning requires a network connection.
- Start and end points can be obtained in multiple ways, such as using the coordinate picker to query coordinates, or using the POI search in the Search SDK to find points of interest.
- Three methods are available for walking route planning, as shown in the table below:
Recommendation: Use the -calculateWalkRouteWithStartPOIInfo:endPOIInfo:strategy: method. The SDK automatically completes additional information based on the POIId or startPOIInfo.startAngle, resulting in a more reasonable route and reducing detours.
Usage
Step 1: Set 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 a walking route using POI
[[AMapNaviWalkManager sharedInstance] calculateWalkRouteWithStartPOIInfo:self.startPOIInfo
endPOIInfo:self.endPOIInfo
strategy:AMapNaviTravelStrategyMultipleDefault];Step 3: Handle the Result
When the walking route is calculated successfully, the -walkManagerOnCalculateRouteSuccess: callback is triggered. In this callback, you can display the route or start navigation directly.
- (void)walkManagerOnCalculateRouteSuccess:(AMapNaviWalkManager *)walkManager
{
NSLog(@"onCalculateRouteSuccess");
// Display the route or start navigation
}