Learning Goals:
-Positioning function
-Geo-coding
-User position in the following
-Pin
In iOS development, to join a location and map, you must import 2 frameworks for development.
Map Kit: For maps
Core location: For geolocation
To implement maps and navigation, it is often necessary to familiarize yourself with the positioning function and navigate through the core location framework in iOS. The Core location itself can be used alone, and the map development framework Mapkit is completely independent,
But often map development should be used in conjunction with the positioning framework. Positioning, geocoding (including anti-coding) features are primarily included in the core location.
Achieve positioning
#import "ViewController.h" #import <CoreLocation/CoreLocation.h> @interface Viewcontroller () < Cllocationmanagerdelegate> @property (nonatomic, strong) Cllocationmanager *manager; @end @implementation viewcontroller//Import the Corelocation.framework framework into the corresponding class by importing corelocation/corelocation.h-(void) viewdidload {[Super] before using the locate viewdidload];//determine if the server is open BOOL isOpen = [Cllocationmanager locationservicesenabled]; if (IsOpen) {NSLog (@ "Location service open"); }else{NSLog (@ "Pro, your mobile location service is not open"); }//Determine the authentication status/*1. The user has not made any judgment kclauthorizationstatusnotdetermined = 0,2. User Disabled location Service Information kclauthorizationstatusdenied = 23. Access location service in the background kclauthorizationstatusauthorizedalways = 3 ns_enum_available (NA, 8_0) —————— This enumeration value is added after the iOS8.0, which is ios7,6 ,... Without this enumeration value, 4. Access location service at the front desk kclauthorizationstatusauthorizedwheninuse = 4*///Get authentication status Nsinteger stuatus = [Cllocatio Nmanager Authorizationstatus]; NSLog (@ "%ld", stuatus); Switch (stuatus) {case 0:nslog (@ "Kclauthorizationstatusnotdetermined--no decision "); Break Case 1:nslog (@ "kclauthorizationstatusrestricted--not licensed"); Break Case 2:nslog (@ "kclauthorizationstatusdenied--prohibited use"); Break Case 3:nslog (@ "kclauthorizationstatusauthorizedalways--always Allow"); Break Case 4:nslog (@ "kclauthorizationstatusauthorizedwheninuse--enable"); Break Default:break; //3. Request the app to access the phone's location service//3.1 Modify the plist file//nslocationalwaysusagedescription---I want to also access your location in the background//nslocationwh Eninuseusagedescription---I want to use your location when my app is open, OK? _manager = [[Cllocationmanager alloc]init]; _manager.delegate = self; float Version = [[[Uidevice Currentdevice] systemversion] floatvalue]; NSLog (@ "%f%@", Version,[[uidevice Currentdevice] systemName]); if (version >= 8.0) {[_manager requestalwaysauthorization]; This method is called when the}}//User license state changes-(void) LocatiOnmanager: (Cllocationmanager *) Manager didchangeauthorizationstatus: (clauthorizationstatus) status{NSLog (@ "Authentication status changed "); } @end
UI Advanced ___ Location, map