Document Navigation SDK for iOS Guides Location Custom Location Source

Custom Location Source

Passing external location data means the navigation SDK no longer uses the system's location data for driving. Instead, the SDK uses the location data you provide as the standard for route calculation without a starting point and for real-time navigation.

To implement external location data, follow these steps:

Step 1: Enable External Location Data

Call the setEnableExternalLocation method of AMapNaviDriveManager to enable the use of external location data.

// Enable external location data
[[AMapNaviDriveManager sharedInstance] setEnableExternalLocation:YES];

Step 2: Pass External Location Data

Call the setExternalLocation method of AMapNaviDriveManager to pass external location data.

Note: The location data you pass must be in the WGS84 coordinate system (with isAMapCoordinate set to NO) or the AMap coordinate system (with isAMapCoordinate set to YES). The following parameters are all required: longitude, latitude, speed, accuracy, course, and timestamp.

// Note: Use the current time as the timestamp
CLLocation *newLocation = [[CLLocation alloc] initWithCoordinate:location.coordinate
                                                        altitude:location.altitude
                                              horizontalAccuracy:location.horizontalAccuracy
                                                verticalAccuracy:location.verticalAccuracy
                                                          course:location.course
                                                           speed:location.speed
                                                       timestamp:[NSDate dateWithTimeIntervalSinceNow:0]];
// Pass coordinates in the WGS84 coordinate system
[[AMapNaviDriveManager sharedInstance] setExternalLocation:newLocation isAMapCoordinate:NO];