Initialization & Compliance
Add the AMAP API Key
Import the base SDK header file and configure your AMAP API key as shown below.
#import <AMapFoundationKit/AMapFoundationKit.h>
[AMapServices sharedServices].apiKey = @"YOUR_API_KEY";Privacy Compliance Interface
Map
1. The following interfaces handle privacy compliance for the map:
/**
* @brief Updates the app's privacy dialog display status and whether the dialog
* includes the AMap SDK privacy agreement. Note: Must be called before
* instantiating MAMapView. (since 8.1.0)
* @param showStatus The privacy dialog display status.
* @param containStatus Whether the dialog contains the AMap SDK privacy agreement.
*/
+ (void)updatePrivacyShow:(AMapPrivacyShowStatus)showStatus
privacyInfo:(AMapPrivacyInfoStatus)containStatus;
/**
* @brief Updates the user's authorization status for the AMap SDK privacy agreement.
* Note: Must be called before instantiating MAMapView. (since 8.1.0)
* @param agreeStatus The user's authorization status.
*/
+ (void)updatePrivacyAgree:(AMapPrivacyAgreeStatus)agreeStatus;2. Before creating a MAMapView (or MAOfflineMap, MAOfflineMapViewController, MATraceManager, etc.), you must ensure privacy policy compliance. Call the following check interfaces before setting up the map:
[MAMapView updatePrivacyShow:AMapPrivacyShowStatusDidShow
privacyInfo:AMapPrivacyInfoStatusDidContain];
[MAMapView updatePrivacyAgree:AMapPrivacyAgreeStatusDidAgree];3. Before constructing a MAMapView, display a user authorization dialog that includes the AMap SDK privacy agreement. The map features will work normally only after the user has authorized the agreement. Otherwise, MAMapView initialization fails and returns nil.
Search
1. The following interfaces handle privacy compliance for search:
/**
* @brief Updates the app's privacy dialog display status and whether the dialog
* includes the AMap SDK privacy agreement. Note: Must be called before
* instantiating AMapSearchAPI. (since 8.1.0)
* @param showStatus The privacy dialog display status.
* @param containStatus Whether the dialog contains the AMap SDK privacy agreement.
*/
+ (void)updatePrivacyShow:(AMapPrivacyShowStatus)showStatus
privacyInfo:(AMapPrivacyInfoStatus)containStatus;
/**
* @brief Updates the user's authorization status for the AMap SDK privacy agreement.
* Note: Must be called before instantiating AMapSearchAPI. (since 8.1.0)
* @param agreeStatus The user's authorization status.
*/
+ (void)updatePrivacyAgree:(AMapPrivacyAgreeStatus)agreeStatus;2. Before creating an AMapSearchAPI (or AMapNearbySearchManager), you must ensure privacy policy compliance. Call the following check interfaces before setting up the search:
[AMapSearchAPI updatePrivacyShow:AMapPrivacyShowStatusDidShow
privacyInfo:AMapPrivacyInfoStatusDidContain];
[AMapSearchAPI updatePrivacyAgree:AMapPrivacyAgreeStatusDidAgree];3. Before constructing an AMapSearchAPI, display a user authorization dialog that includes the AMap SDK privacy agreement. The search features will work normally only after the user has authorized the agreement. Otherwise, AMapSearchAPI initialization fails and returns nil.
Region & Language Settings
Search SDK
AMapSearchAPI * search = [[AMapSearchAPI alloc] init];
search. language = @"zh-Hant-HK" ;Map SDK
/**
* Returns whether the current environment is outside of mainland China.
*/
@property (nonatomic, readonly) BOOL isOverSea;
/// Country code property
@property (nonatomic, copy) NSString *countryCode;
[AMapServices sharedServices].countryCode = @"SG";
/// Language type property
@property (nonatomic, assign) AMapRegionLanguageType regionLanguageType;
[AMapServices sharedServices].regionLanguageType = AMapRegionLanguageTypeEn;
// Set the current coordinates
- (void)setCurrentLocation:(CLLocationCoordinate2D)location;
Compatibility
The SDK supports iOS 7.0 and later.