百度定位SDK for iOS v1.6 类参考
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 _Nonnull 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 
68 @protocol BMKLocationManagerDelegate;
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 
108 @property (nonatomic, assign) BOOL isNeedNewVersionReGeocode;
109 
110 
112 @property(nonatomic, retain, nullable) NSString * userID;
113 
114 
115 
123 - (BOOL)requestLocationWithReGeocode:(BOOL)withReGeocode withNetworkState:(BOOL)withNetWorkState completionBlock:(BMKLocatingCompletionBlock _Nonnull)completionBlock;
124 
128 - (void)startUpdatingLocation;
129 
133 - (void)stopUpdatingLocation;
134 
138 - (void)requestNetworkState;
139 
140 
145 + (BOOL)headingAvailable;
146 
150 - (void)startUpdatingHeading;
151 
155 - (void)stopUpdatingHeading;
156 
160 - (void)tryIndoorLocation;
161 
165 - (void)stopIndoorLocation;
166 
167 
175 + (CLLocationCoordinate2D) BMKLocationCoordinateConvert:(CLLocationCoordinate2D) coordinate SrcType:(BMKLocationCoordinateType)srctype DesType:(BMKLocationCoordinateType)destype;
176 
183 + (BOOL) BMKLocationDataAvailableForCoordinate:(CLLocationCoordinate2D)coordinate withCoorType:(BMKLocationCoordinateType)coortype;
184 
185 
186 @end
187 
188 #pragma mark - BMKLocationManagerDelegate
189 
190 
192 @protocol BMKLocationManagerDelegate <NSObject>
193 
194 @optional
195 
202 - (void)BMKLocationManager:(BMKLocationManager * _Nonnull)manager doRequestAlwaysAuthorization:(CLLocationManager * _Nonnull)locationManager;
203 
209 - (void)BMKLocationManager:(BMKLocationManager * _Nonnull)manager didFailWithError:(NSError * _Nullable)error;
210 
211 
218 - (void)BMKLocationManager:(BMKLocationManager * _Nonnull)manager didUpdateLocation:(BMKLocation * _Nullable)location orError:(NSError * _Nullable)error;
219 
225 - (void)BMKLocationManager:(BMKLocationManager * _Nonnull)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status;
226 
227 
232 - (BOOL)BMKLocationManagerShouldDisplayHeadingCalibration:(BMKLocationManager * _Nonnull)manager;
233 
239 - (void)BMKLocationManager:(BMKLocationManager * _Nonnull)manager
240  didUpdateHeading:(CLHeading * _Nullable)heading;
241 
248 - (void)BMKLocationManager:(BMKLocationManager * _Nonnull)manager
249  didUpdateNetworkState:(BMKLocationNetworkState)state orError:(NSError * _Nullable)error;
250 
251 
252 @end
253 
254 
void tryIndoorLocation()
该方法为BMKLocationManager尝试使用高精度室内定位。在特定的室内场景下会有更高精度的定位回调,只在室内...
BMKLocationCoordinateType coordinateType
设定定位坐标系类型。默认为 BMKLocationCoordinateTypeGCJ02。
Definition: BMKLocationManager.h:89
void stopUpdatingLocation()
停止连续定位。调用此方法会cancel掉所有的单次定位请求,可以用来取消单次定位。
void stopIndoorLocation()
该方法为BMKLocationManager会关闭高精度室内定位,只在室内定位版本生效。
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停止设备朝向事件回调。
BOOL isNeedNewVersionReGeocode
定位sdk-v1.3之后,开发者可以选择是否需要最新版本rgc数据,默认是不需要NO;YES的情况下,定位sdk会实时返...
Definition: BMKLocationManager.h:108
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
NSString * userID
开发者可以指定该用户的id,用于后续统一识别用户,便于查找问题
Definition: BMKLocationManager.h:112
BOOL headingAvailable()
该方法返回设备是否支持设备朝向事件回调。
描述百度iOS 定位数据
Definition: BMKLocation.h:27
NSInteger reGeocodeTimeout
指定单次定位逆地理超时时间,默认为10s。最小值是2s。注意单次定位请求前设置。
Definition: BMKLocationManager.h:102
CLLocationDistance distanceFilter
设定定位的最小更新距离。默认为 kCLDistanceFilterNone。
Definition: BMKLocationManager.h:80
BOOL allowsBackgroundLocationUpdates
是否允许后台定位。默认为NO。只在iOS 9.0及之后起作用。设置为YES的时候必须保证 Background Modes 中的 Lo...
Definition: BMKLocationManager.h:96
void startUpdatingLocation()
开始连续定位。调用此方法会cancel掉所有的单次定位请求。