In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article will explain in detail the complete steps of iOS calling Amap SDK. The content of the article is of high quality, so the editor will share it with you for reference. I hope you will have some understanding of the relevant knowledge after reading this article.
Preparatory work:
Install CocoaPods download SDK using the same method as downloading third-party libraries
The methods are as follows:
(1) Open the terminal, and enter the path of the cd file to the created project file.
(2) enter pod init to create a Podfile file for the project
(3) add pod 'AMap3DMap' or pod' AMap2DMap' to the Podfile file
Among them, 3D is 3D map, 2D is 2D map, you can choose one of them to add, if all is selected, there will be a conflict and the installation of SDK will fail.
(4) enter pod install to download SDK (if the downloaded SDK is not the latest version, enter pod repo update to update) after download, you can click the .xc workspace file to enter the project and write code. In addition, you need to register as a personal developer of Amap and go to the "Gaode Open platform console" to apply for iOS Key. This iOS key needs to be used in actual project writing.
The method to apply for key is as follows:
Log in or register
1. If you have not already registered, please click here to complete the registration.
2. If you have already registered, please log in and apply for key. The entry for application and registration is as follows:
Create an application
Go to "console-Application Management-create New Application" and click here to enter.
Apply to add key to the application
1. Click "+" on the left to add Key.
2. Enter the necessary fields. At this time, you need to select the correct key type.
Select the iOS platform in the above figure, and enter the security code Bundle ID: after the selection. The security code is obtained as follows:
After filling in everything, we can get the key we need.
Then go to the internal settings of the project:
In order to enhance data access security, 1.iOS9 has changed all http requests to https. In order to be able to use map SDK in iOS9, you need to configure the following in "Info.plist", otherwise the use of SDK will be affected (see figure below):
We need to create an Allow Aebitrary Loads under App Transport Security Settings and set its Type to Value of type Boolean to YES; if there is no App Transport Security Settings itself, we need to create a
two。 Configure Gaud key to AppDelegate.m file:
# import / / need to introduce AMapFoundationKit.h header file. (BOOL) application: (UIApplication *) application didFinishLaunchingWithOptions: (NSDictionary *) launchOptions {/ / modify your Key below to the key you just obtained; [AMapServices sharedServices]. ApiKey = @ "your Key";. }
3. How to load the map:
Initialize and initialize the map in the corresponding method in the ViewController.m file:
(1) import MAMapKit.h header file
(2) construct MAMapView object
(3) add MAMapView to Subview.
For 3D vector maps, add code to the viewDidLoad method:
# import-(void) viewDidLoad {[super viewDidLoad]; / / Do any additional setup after loading the view, typically from a nib. / / initialize the map MAMapView * _ mapView = [[MAMapView alloc] initWithFrame:self.view.bounds]; / / add the map to view [self.view addSubview:_mapView];} important points:
After we have implemented the above operations, we are still unable to load the map successfully. At this time, the runtime will prompt Amap about privacy compliance issues related to SDK. This is because laws and regulations must pass this test for the content required by APP, otherwise the map view cannot be displayed. But don't panic, see below:
Compliance check must be performed before constructing MAMapView (MAOfflineMap,MAOfflineMapViewController,MATraceManager, etc.), and privacy policy compliance must be ensured before setting APIs. Check APIs are as follows:
[MAMapView updatePrivacyShow:AMapPrivacyShowStatusDidShow privacyInfo:AMapPrivacyInfoStatusDidContain]; [MAMapView updatePrivacyAgree:AMapPrivacyAgreeStatusDidAgree]
The view of the map can be successfully loaded before the above two lines of interface code are added to the code that loads the map view.
That is, the code in ViewController.m is written in the following form:
# import-(void) viewDidLoad {[super viewDidLoad]; / / Do any additional setup after loading the view, typically from a nib. / / add privacy compliance interface code [MAMapView updatePrivacyShow:AMapPrivacyShowStatusDidShow privacyInfo:AMapPrivacyInfoStatusDidContain]; [MAMapView updatePrivacyAgree:AMapPrivacyAgreeStatusDidAgree]; / / initialize the map MAMapView * _ mapView = [[MAMapView alloc] initWithFrame:self.view.bounds]; / / add the map to view [self.view addSubview:_mapView];}
At this point, our entire process is over, and the actual running result is as follows:
You can see that the map view is already displayed on our mobile phones.
On the iOS call Amap SDK how the complete steps are shared here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.