百度定位SDK for iOS v1.2 类参考
BMKLocationManager.h
1 //
2 // BMKLocationManager.h
3 // BMKLocationKit
4 //
5 // Created by baidu on 2017/3/2.
6 // Copyright © 2017年 baidu. All rights reserved.
7 //
8 
9 
10 #import <Foundation/Foundation.h>
11 #import <CoreLocation/CoreLocation.h>
12 #import "BMKLocationReGeocode.h"
13 #import "BMKLocation.h"
14 
18 typedef NS_ENUM(NSUInteger, BMKLocationCoordinateType)
19 {
20  BMKLocationCoordinateTypeBMK09LL = 0,
21  BMKLocationCoordinateTypeBMK09MC,
22  BMKLocationCoordinateTypeWGS84,
23  BMKLocationCoordinateTypeGCJ02
24 };
25 
29 typedef NS_ENUM(int, BMKLocationNetworkState) {
30  BMKLocationNetworkStateUnknown = 0,
31  BMKLocationNetworkStateWifi,
32  BMKLocationNetworkStateWifiHotSpot,
33  BMKLocationNetworkStateMobile2G,
34  BMKLocationNetworkStateMobile3G,
35  BMKLocationNetworkStateMobile4G
36 
37 };
38 
39 
41 
42 FOUNDATION_EXPORT NSErrorDomain const BMKLocationErrorDomain;
43 
45 typedef NS_ENUM(NSInteger, BMKLocationErrorCode)
46 {
47  BMKLocationErrorUnKnown = 0,
48  BMKLocationErrorLocFailed = 1,
49  BMKLocationErrorDenied = 2,
50  BMKLocationErrorNetWork = 3,
51  BMKLocationErrorHeadingFailed = 4,
52  BMKLocationErrorGetExtraNetworkFailed = 5,
53  BMKLocationErrorGetExtraParseFailed = 6,
54  BMKLocationErrorFailureAuth = 7,
55 };
56 
57 
64 typedef void (^BMKLocatingCompletionBlock)(BMKLocation * _Nullable location, BMKLocationNetworkState state , NSError * _Nullable error);
65 
66 
67 
69 
70 #pragma mark - BMKLocationManager
71 
72 
74 @interface BMKLocationManager : NSObject
75 
77 @property (nonatomic, weak, nullable) id<BMKLocationManagerDelegate> delegate;
78 
80 @property(nonatomic, assign) CLLocationDistance distanceFilter;
81 
83 @property(nonatomic, assign) CLLocationAccuracy desiredAccuracy;
84 
86 @property(nonatomic, assign) CLActivityType activityType;
87 
89 @property(nonatomic, assign) BMKLocationCoordinateType coordinateType;
90 
92 @property(nonatomic, assign) BOOL pausesLocationUpdatesAutomatically;
93 
94 
96 @property(nonatomic, assign) BOOL allowsBackgroundLocationUpdates;
97 
99 @property(nonatomic, assign) NSInteger locationTimeout;
100 
102 @property(nonatomic, assign) NSInteger reGeocodeTimeout;
103 
105 @property (nonatomic, assign) BOOL locatingWithReGeocode;
106 
107 
115 - (BOOL)requestLocationWithReGeocode:(BOOL)withReGeocode withNetworkState:(BOOL)withNetWorkState completionBlock:(BMKLocatingCompletionBlock _Nonnull)completionBlock;
116 
120 - (void)startUpdatingLocation;
121 
125 - (void)stopUpdatingLocation;
126 
130 - (void)requestNetworkState;
131 
132 
137 + (BOOL)headingAvailable;
138 
142 - (void)startUpdatingHeading;
143 
147 - (void)stopUpdatingHeading;
148 
149 
157 + (CLLocationCoordinate2D) BMKLocationCoordinateConvert:(CLLocationCoordinate2D) coordinate SrcType:(BMKLocationCoordinateType)srctype DesType:(BMKLocationCoordinateType)destype;
158 
165 + (BOOL) BMKLocationDataAvailableForCoordinate:(CLLocationCoordinate2D)coordinate withCoorType:(BMKLocationCoordinateType)coortype;
166 
167 
168 @end
169 
170 #pragma mark - BMKLocationManagerDelegate
171 
172 
174 @protocol BMKLocationManagerDelegate <NSObject>
175 
176 @optional
177 
183 - (void)BMKLocationManager:(BMKLocationManager * _Nonnull)manager didFailWithError:(NSError * _Nullable)error;
184 
185 
192 - (void)BMKLocationManager:(BMKLocationManager * _Nonnull)manager didUpdateLocation:(BMKLocation * _Nullable)location orError:(NSError * _Nullable)error;
193 
199 - (void)BMKLocationManager:(BMKLocationManager * _Nonnull)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status;
200 
201 
206 - (BOOL)BMKLocationManagerShouldDisplayHeadingCalibration:(BMKLocationManager * _Nonnull)manager;
207 
213 - (void)BMKLocationManager:(BMKLocationManager * _Nonnull)manager
214  didUpdateHeading:(CLHeading * _Nullable)heading;
215 
222 - (void)BMKLocationManager:(BMKLocationManager * _Nonnull)manager
223  didUpdateNetworkState:(BMKLocationNetworkState)state orError:(NSError * _Nullable)error;
224 
225 
226 @end
227 
228 
BMKLocationCoordinateType coordinateType
设定定位坐标系类型。默认为 BMKLocationCoordinateTypeGCJ02。
Definition: BMKLocationManager.h:89
void stopUpdatingLocation()
停止连续定位。调用此方法会cancel掉所有的单次定位请求,可以用来取消单次定位。
void requestNetworkState()
请求网络状态结果回调。
BMKLocationManager类。初始化之前请设置 BMKLocationAuth 中的APIKey,否则将无法正常使用服务.
Definition: BMKLocationManager.h:74
id< BMKLocationManagerDelegate > delegate
实现了 BMKLocationManagerDelegate 协议的类指针。
Definition: BMKLocationManager.h:77
CLLocationAccuracy desiredAccuracy
设定定位精度。默认为 kCLLocationAccuracyBest。
Definition: BMKLocationManager.h:83
void stopUpdatingHeading()
该方法为BMKLocationManager停止设备朝向事件回调。
NSInteger locationTimeout
指定单次定位超时时间,默认为10s。最小值是2s。注意单次定位请求前设置。注意: 单次定位超时时间从确定了定...
Definition: BMKLocationManager.h:99
BOOL pausesLocationUpdatesAutomatically
指定定位是否会被系统自动暂停。默认为NO。
Definition: BMKLocationManager.h:92
void startUpdatingHeading()
该方法为BMKLocationManager开始设备朝向事件回调。
CLActivityType activityType
设定定位类型。默认为 CLActivityTypeAutomotiveNavigation。
Definition: BMKLocationManager.h:86
BOOL locatingWithReGeocode
连续定位是否返回逆地理信息,默认YES。
Definition: BMKLocationManager.h:105
BOOL headingAvailable()
该方法返回设备是否支持设备朝向事件回调。
描述百度iOS 定位数据
Definition: BMKLocation.h:27
NSInteger reGeocodeTimeout
指定单次定位逆地理超时时间,默认为10s。最小值是2s。注意单次定位请求前设置。
Definition: BMKLocationManager.h:102
CLLocationDistance distanceFilter
设定定位的最小更新距离。默认为 kCLDistanceFilterNone。
Definition: BMKLocationManager.h:80
BMKLocationManagerDelegate 协议定义了发生错误时的错误回调方法,连续定位的回调方法等。 ...
Definition: BMKLocationManager.h:174
BOOL allowsBackgroundLocationUpdates
是否允许后台定位。默认为NO。只在iOS 9.0及之后起作用。设置为YES的时候必须保证 Background Modes 中的 Lo...
Definition: BMKLocationManager.h:96
void startUpdatingLocation()
开始连续定位。调用此方法会cancel掉所有的单次定位请求。