哈哈哈
3 years ago
45 changed files with 2442 additions and 443 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,4 @@
|
||||
//
|
||||
// Use this file to import your target's public headers that you would like to expose to Swift.
|
||||
//
|
||||
|
Binary file not shown.
Binary file not shown.
@ -0,0 +1,141 @@
|
||||
//
|
||||
// BMKGeoFenceManager.h
|
||||
// BMKLocationKit
|
||||
//
|
||||
// Created by baidu on 2017/3/2.
|
||||
// Copyright © 2017年 baidu. All rights reserved.
|
||||
//
|
||||
|
||||
#import "BMKGeoFenceRegion.h" |
||||
|
||||
@protocol BMKGeoFenceManagerDelegate; |
||||
|
||||
///地理围栏监听状态类型
|
||||
typedef NS_OPTIONS(NSUInteger, BMKGeoFenceActiveAction) |
||||
{ |
||||
BMKGeoFenceActiveActionNone = 0, ///< 不进行监听
|
||||
BMKGeoFenceActiveActionInside = 1 << 0, ///< 在范围内
|
||||
BMKGeoFenceActiveActionOutside = 1 << 1, ///< 在范围外
|
||||
BMKGeoFenceActiveActionStayed = 1 << 2, ///< 停留(在范围内超过10分钟)
|
||||
}; |
||||
|
||||
///BMKGeoFence errorDomain
|
||||
FOUNDATION_EXPORT NSErrorDomain const _Nonnull BMKGeoFenceErrorDomain; |
||||
|
||||
///地理围栏错误码
|
||||
typedef NS_ENUM(NSInteger, BMKGeoFenceErrorCode) { |
||||
BMKGeoFenceErrorUnknown = 1, ///< 未知错误
|
||||
BMKGeoFenceErrorInvalidParameter = 2, ///< 参数错误
|
||||
BMKGeoFenceErrorFailureConnection = 3, ///< 网络连接异常
|
||||
BMKGeoFenceErrorFailureAuth = 4, ///< 鉴权失败
|
||||
BMKGeoFenceErrorNoValidFence = 5, ///< 无可用围栏
|
||||
BMKGeoFenceErroFailureLocating = 6, ///< 定位错误
|
||||
}; |
||||
|
||||
|
||||
///地理围栏管理类
|
||||
@interface BMKGeoFenceManager : NSObject |
||||
|
||||
|
||||
///实现了 BMKGeoFenceManagerDelegate 协议的类指针。
|
||||
@property (nonatomic, weak, nullable) id<BMKGeoFenceManagerDelegate> delegate; |
||||
|
||||
|
||||
///需要进行通知的行为,默认为BMKGeoFenceActiveActionInside。
|
||||
@property (nonatomic, assign) BMKGeoFenceActiveAction activeAction; |
||||
|
||||
|
||||
///指定定位是否会被系统自动暂停。默认为NO。
|
||||
@property (nonatomic, assign) BOOL pausesLocationUpdatesAutomatically; |
||||
|
||||
|
||||
///是否允许后台定位。默认为NO。只在iOS 9.0及之后起作用。设置为YES的时候必须保证 Background Modes 中的 Location updates 处于选中状态,否则会抛出异常。
|
||||
@property (nonatomic, assign) BOOL allowsBackgroundLocationUpdates; |
||||
|
||||
|
||||
/**
|
||||
* @brief 添加一个圆形围栏 |
||||
* @param center 围栏的中心点经纬度坐标 |
||||
* @param radius 围栏的半径,单位:米,要求大于0 |
||||
* @param type 围栏的坐标系类型 |
||||
* @param customID 用户自定义ID,可选,SDK原值返回 |
||||
*/ |
||||
- (void)addCircleRegionForMonitoringWithCenter:(CLLocationCoordinate2D)center radius:(CLLocationDistance)radius coorType:(BMKLocationCoordinateType)type customID:(NSString * _Nullable)customID; |
||||
|
||||
|
||||
/**
|
||||
* @brief 根据经纬度坐标数据添加一个闭合的多边形围栏,点与点之间按顺序尾部相连, 第一个点与最后一个点相连 |
||||
* @param coordinates 经纬度坐标点数据,coordinates对应的内存会拷贝,调用者负责该内存的释放 |
||||
* @param count 经纬度坐标点的个数,不可小于3个 |
||||
* @param type 围栏的坐标系类型 |
||||
* @param customID 用户自定义ID,可选,SDK原值返回 |
||||
*/ |
||||
- (void)addPolygonRegionForMonitoringWithCoordinates:(CLLocationCoordinate2D * _Nonnull)coordinates count:(NSInteger)count coorType:(BMKLocationCoordinateType)type customID:(NSString * _Nullable)customID; |
||||
|
||||
|
||||
/**
|
||||
* @brief 根据customID获得指定的围栏,如果customID传nil,则返回全部围栏 |
||||
* @param customID 用户执行添加围栏函数时传入的customID |
||||
* @return 获得的围栏构成的数组,如果没有结果,返回nil |
||||
*/ |
||||
- (NSArray * _Nullable)geoFenceRegionsWithCustomID:(NSString * _Nullable)customID; |
||||
|
||||
|
||||
/**
|
||||
* @brief 移除指定围栏 |
||||
* @param region 要停止监控的围栏 |
||||
*/ |
||||
- (void)removeTheGeoFenceRegion:(BMKGeoFenceRegion * _Nonnull)region; |
||||
|
||||
|
||||
/**
|
||||
* @brief 移除指定customID的围栏 |
||||
* @param customID 用户执行添加围栏函数时传入的customID |
||||
*/ |
||||
- (void)removeGeoFenceRegionsWithCustomID:(NSString * _Nullable)customID; |
||||
|
||||
|
||||
/**
|
||||
* @brief 移除所有围栏 |
||||
*/ |
||||
- (void)removeAllGeoFenceRegions; |
||||
|
||||
|
||||
@end |
||||
|
||||
|
||||
|
||||
///地理围栏代理协议,该协议定义了获取地理围栏相关回调方法,包括添加、状态改变等。
|
||||
@protocol BMKGeoFenceManagerDelegate <NSObject> |
||||
|
||||
@optional |
||||
|
||||
/**
|
||||
* @brief 为了适配app store关于新的后台定位的审核机制(app store要求如果开发者只配置了使用期间定位,则代码中不能出现申请后台定位的逻辑),当开发者在plist配置NSLocationAlwaysUsageDescription或者NSLocationAlwaysAndWhenInUseUsageDescription时,需要在该delegate中调用后台定位api:[locationManager requestAlwaysAuthorization]。开发者如果只配置了NSLocationWhenInUseUsageDescription,且只有使用期间的定位需求,则无需在delegate中实现逻辑。 |
||||
* @param manager 定位 BMKGeoFenceManager 类。 |
||||
* @param locationManager 系统 CLLocationManager 类 。 |
||||
* @since 1.7.0 |
||||
*/ |
||||
- (void)BMKGeoFenceManager:(BMKGeoFenceManager * _Nonnull)manager doRequestAlwaysAuthorization:(CLLocationManager * _Nonnull)locationManager; |
||||
|
||||
/**
|
||||
* @brief 添加地理围栏完成后的回调,成功与失败都会调用 |
||||
* @param manager 地理围栏管理类 |
||||
* @param regions 成功添加的一个或多个地理围栏构成的数组 |
||||
* @param customID 用户执行添加围栏函数时传入的customID |
||||
* @param error 添加失败的错误信息 |
||||
*/ |
||||
- (void)BMKGeoFenceManager:(BMKGeoFenceManager * _Nonnull)manager didAddRegionForMonitoringFinished:(NSArray <BMKGeoFenceRegion *> * _Nullable)regions customID:(NSString * _Nullable)customID error:(NSError * _Nullable)error; |
||||
|
||||
|
||||
/**
|
||||
* @brief 地理围栏状态改变时回调,当围栏状态的值发生改变,定位失败都会调用 |
||||
* @param manager 地理围栏管理类 |
||||
* @param region 状态改变的地理围栏 |
||||
* @param customID 用户执行添加围栏函数时传入的customID |
||||
* @param error 错误信息,如定位相关的错误 |
||||
*/ |
||||
- (void)BMKGeoFenceManager:(BMKGeoFenceManager * _Nonnull)manager didGeoFencesStatusChangedForRegion:(BMKGeoFenceRegion * _Nullable)region customID:(NSString * _Nullable)customID error:(NSError * _Nullable)error; |
||||
|
||||
@end |
||||
|
@ -0,0 +1,114 @@
|
||||
//
|
||||
// BMKGeoFenceRegion.h
|
||||
// BMKLocationKit
|
||||
//
|
||||
// Created by baidu on 2017/3/2.
|
||||
// Copyright © 2017年 baidu. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h> |
||||
#import <CoreLocation/CoreLocation.h> |
||||
#import "BMKLocationManager.h" |
||||
|
||||
///BMKGeoFence Region State
|
||||
typedef NS_ENUM(NSInteger, BMKGeoFenceRegionStatus) |
||||
{ |
||||
BMKGeoFenceRegionStatusUnknown = 0, ///< 未知
|
||||
BMKGeoFenceRegionStatusInside = 1, ///< 在范围内
|
||||
BMKGeoFenceRegionStatusOutside = 1 << 1, ///< 在范围外
|
||||
BMKGeoFenceRegionStatusStayed = 1 << 2, ///< 停留(在范围内超过10分钟)
|
||||
}; |
||||
|
||||
#pragma mark - BMKGeoFenceRegion |
||||
|
||||
|
||||
///地理围栏基类,不可直接使用
|
||||
@interface BMKGeoFenceRegion : NSObject<NSCopying> |
||||
|
||||
|
||||
///BMKGeoFenceRegion的唯一标识符
|
||||
@property (nonatomic, copy, readonly) NSString *identifier; |
||||
|
||||
|
||||
///用户自定义ID,可为nil。
|
||||
@property (nonatomic, copy, readonly) NSString *customID; |
||||
|
||||
|
||||
///坐标点和围栏的关系,比如用户的位置和围栏的关系
|
||||
@property (nonatomic, assign) BMKGeoFenceRegionStatus fenceStatus; |
||||
|
||||
///设定围栏坐标系类型。默认为 BMKLocationCoordinateTypeGCJ02。
|
||||
@property(nonatomic, readonly) BMKLocationCoordinateType coordinateType; |
||||
|
||||
///上次发生状态变化的时间
|
||||
@property(nonatomic, assign)NSTimeInterval lastEventTime; |
||||
|
||||
|
||||
/**
|
||||
* @brief 判断位置与围栏状态 |
||||
* @param CLLocationCoordinate2D 坐标值 |
||||
* @return 返回BMKGeoFenceRegionStatus状态 |
||||
*/ |
||||
-(BMKGeoFenceRegionStatus)judgeStatusWithCoor:(CLLocationCoordinate2D)coor; |
||||
|
||||
@end |
||||
|
||||
|
||||
#pragma mark - BMKLocationCircleRegion |
||||
|
||||
|
||||
///圆形地理围栏
|
||||
@interface BMKGeoFenceCircleRegion : BMKGeoFenceRegion |
||||
|
||||
|
||||
///中心点的经纬度坐标
|
||||
@property (nonatomic, readonly) CLLocationCoordinate2D center; |
||||
|
||||
|
||||
///半径,单位:米
|
||||
@property (nonatomic, readonly) CLLocationDistance radius; |
||||
|
||||
/**
|
||||
* @brief 构造圆形围栏 |
||||
* @param customid 用户自定义ID |
||||
* @param identityid 识别id |
||||
* @param center 中心坐标 |
||||
* @param radius 围栏半径 |
||||
* @param type 坐标系类型 |
||||
* @return BMKGeoFenceCircleRegion id |
||||
*/ |
||||
- (id)initWithCustomID:(NSString *)customid identityID:(NSString *)identityid center:(CLLocationCoordinate2D)center radius:(CLLocationDistance)radius coor:(BMKLocationCoordinateType)type; |
||||
|
||||
|
||||
|
||||
@end |
||||
|
||||
|
||||
#pragma mark -BMKGeoFencePolygonRegion |
||||
|
||||
|
||||
///多边形地理围栏
|
||||
@interface BMKGeoFencePolygonRegion : BMKGeoFenceRegion |
||||
|
||||
|
||||
///经纬度坐标点数据
|
||||
@property (nonatomic, readonly) CLLocationCoordinate2D *coordinates; |
||||
|
||||
|
||||
///经纬度坐标点的个数
|
||||
@property (nonatomic, readonly) NSInteger count; |
||||
|
||||
|
||||
/**
|
||||
* @brief 构造多边形围栏 |
||||
* @param customid 用户自定义ID |
||||
* @param identityid 识别id |
||||
* @param coor 多边形顶点 |
||||
* @param count 顶点个数 |
||||
* @param type 坐标系类型 |
||||
* @return BMKGeoFencePolygonRegion id |
||||
*/ |
||||
- (id)initWithCustomID:(NSString *)customid identityID:(NSString *)identityid coor:(CLLocationCoordinate2D *)coor count:(NSInteger)count coor:(BMKLocationCoordinateType)type; |
||||
|
||||
@end |
||||
|
@ -0,0 +1,97 @@
|
||||
//
|
||||
// BMKLocation.h
|
||||
// LocationComponent
|
||||
//
|
||||
// Created by baidu on 2017/8/16.
|
||||
// Copyright © 2017年 baidu. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef BMKLocation_h |
||||
#define BMKLocation_h |
||||
|
||||
#import <CoreLocation/CoreLocation.h> |
||||
#import "BMKLocationReGeocode.h" |
||||
|
||||
/**
|
||||
* BMKLocationProvider 位置数据来源,分iOS系统定位和其他定位服务结果两种,目前仅支持iOS系统定位服务 |
||||
* |
||||
*/ |
||||
typedef NS_ENUM(int, BMKLocationProvider) { |
||||
|
||||
BMKLocationProviderIOS = 0, //!<位置来源于iOS本身定位
|
||||
BMKLocationProviderOther //!<位置来源于其他定位服务
|
||||
|
||||
}; |
||||
|
||||
///描述百度iOS 定位数据
|
||||
@interface BMKLocation : NSObject |
||||
|
||||
///BMKLocation 位置数据
|
||||
@property(nonatomic, copy, readonly) CLLocation * _Nullable location; |
||||
|
||||
///BMKLocation 地址数据
|
||||
@property(nonatomic, copy) BMKLocationReGeocode * _Nullable rgcData; |
||||
|
||||
///BMKLocation 位置来源
|
||||
@property(nonatomic, assign) BMKLocationProvider provider; |
||||
|
||||
///BMKLocation 位置ID
|
||||
@property(nonatomic, retain) NSString * _Nullable locationID; |
||||
|
||||
/*
|
||||
* floorString |
||||
* |
||||
* Discussion: |
||||
* 室内定位成功时返回的楼层信息,ex:f1 |
||||
*/ |
||||
@property(readonly, nonatomic, copy, nullable) NSString *floorString; |
||||
|
||||
/*
|
||||
* buildingID |
||||
* |
||||
* Discussion: |
||||
* 室内定位成功时返回的百度建筑物ID |
||||
*/ |
||||
@property(readonly, nonatomic, copy, nullable) NSString *buildingID; |
||||
|
||||
/*
|
||||
* buildingName |
||||
* |
||||
* Discussion: |
||||
* 室内定位成功时返回的百度建筑物名称 |
||||
*/ |
||||
@property(readonly, nonatomic, copy, nullable) NSString *buildingName; |
||||
|
||||
|
||||
/*
|
||||
* extraInfo |
||||
* |
||||
* Discussion: |
||||
* 定位附加信息,如停车位code识别结果、停车位code示例、vdr推算结果置信度等 |
||||
*/ |
||||
@property(readonly, nonatomic, copy, nullable) NSDictionary * extraInfo; |
||||
|
||||
/**
|
||||
* @brief 初始化BMKLocation实例 |
||||
* @param loc CLLocation对象 |
||||
* @param rgc BMKLocationReGeocode对象 |
||||
* @return BMKLocation id |
||||
*/ |
||||
- (id _Nonnull)initWithLocation:(CLLocation * _Nullable)loc withRgcData:(BMKLocationReGeocode * _Nullable)rgc; |
||||
|
||||
/**
|
||||
* @brief 构造BMKLocation |
||||
* @param location CLLocation |
||||
* @param floorString 楼层字符串 |
||||
* @param buildingID 建筑物ID |
||||
* @param buildingName 建筑物名称 |
||||
* @param info 位置附加信息 |
||||
* @return BMKLocation id |
||||
*/ |
||||
-(id _Nonnull)initWithLocation:(CLLocation * _Nullable)location floorString:(NSString * _Nullable)floorString buildingID:(NSString * _Nullable)buildingID |
||||
buildingName:(NSString * _Nullable)buildingName extraInfo:(NSDictionary * _Nullable)info withRgcData:(BMKLocationReGeocode * _Nullable)rgc; |
||||
|
||||
|
||||
@end |
||||
|
||||
#endif /* BMKLocation_h */ |
@ -0,0 +1,56 @@
|
||||
//
|
||||
// BMKLocationAuth.h
|
||||
// LocationComponent
|
||||
//
|
||||
// Created by baidu on 2017/4/10.
|
||||
// Copyright © 2017年 baidu. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef BMKLocationAuth_h |
||||
#define BMKLocationAuth_h |
||||
|
||||
///定位鉴权错误码
|
||||
typedef NS_ENUM(NSInteger, BMKLocationAuthErrorCode) { |
||||
BMKLocationAuthErrorUnknown = -1, ///< 未知错误
|
||||
BMKLocationAuthErrorSuccess = 0, ///< 鉴权成功
|
||||
BMKLocationAuthErrorNetworkFailed = 1, ///< 因网络鉴权失败
|
||||
BMKLocationAuthErrorFailed = 2, ///< KEY非法鉴权失败
|
||||
|
||||
}; |
||||
///通知Delegate
|
||||
@protocol BMKLocationAuthDelegate <NSObject> |
||||
@optional |
||||
|
||||
/**
|
||||
*@brief 返回授权验证错误 |
||||
*@param iError 错误号 : 为0时验证通过,具体参加BMKLocationAuthErrorCode |
||||
*/ |
||||
- (void)onCheckPermissionState:(BMKLocationAuthErrorCode)iError; |
||||
@end |
||||
|
||||
|
||||
///BMKLocationAuth类。用于鉴权
|
||||
@interface BMKLocationAuth : NSObject |
||||
|
||||
///鉴权状态0:成功; 1:网络错误; 2:授权失败
|
||||
@property(nonatomic, readonly, assign) BMKLocationAuthErrorCode permisionState; |
||||
|
||||
/**
|
||||
* @brief 得到BMKLocationAuth的单例 |
||||
*/ |
||||
+ (BMKLocationAuth*)sharedInstance; |
||||
|
||||
|
||||
/**
|
||||
*@brief 启动引擎 |
||||
*@param key 申请的有效key |
||||
*@param delegate 回调是否鉴权成功 |
||||
*/ |
||||
-(void)checkPermisionWithKey:(NSString*)key authDelegate:(id<BMKLocationAuthDelegate>)delegate; |
||||
|
||||
|
||||
@end |
||||
|
||||
|
||||
|
||||
#endif /* BMKLocationAuth_h */ |
@ -0,0 +1,16 @@
|
||||
//
|
||||
// BMKLocationComponent.h
|
||||
// LocationComponent
|
||||
//
|
||||
// Created by Baidu on 3/31/14.
|
||||
// Copyright (c) 2014 baidu. All rights reserved.
|
||||
//
|
||||
|
||||
#import "BMKLocationManager.h" |
||||
#import "BMKLocationKitVersion.h" |
||||
#import "BMKLocationPoi.h" |
||||
#import "BMKLocation.h" |
||||
#import "BMKGeoFenceRegion.h" |
||||
#import "BMKGeoFenceManager.h" |
||||
#import "BMKLocationReGeocode.h" |
||||
#import "BMKLocationAuth.h" |
@ -0,0 +1,30 @@
|
||||
//
|
||||
// BMKLocationKitVersion.h
|
||||
// BMKLocationKit
|
||||
//
|
||||
// Created by baidu on 17/9/9.
|
||||
// Copyright © 2017年 baidu. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef BMKLocationKitVersion_h |
||||
#define BMKLocationKitVersion_h |
||||
|
||||
#import <UIKit/UIKit.h> |
||||
|
||||
/**
|
||||
*获取当前定位sdk 的版本号 |
||||
*当前定位sdk版本 : 2.0.0 |
||||
*@return 返回当前定位sdk 的版本号 |
||||
*/ |
||||
UIKIT_EXTERN NSString* BMKLocationKitVersion(); |
||||
|
||||
/**
|
||||
*获取当前定位sdk 的float版本号 |
||||
*当前定位sdk版本 : 2.0 |
||||
*@return 返回当前定位sdk 的float版本号 |
||||
*/ |
||||
UIKIT_EXTERN float BMKLocationKitFloatVersion(); |
||||
|
||||
|
||||
|
||||
#endif /* BMKLocationKitVersion_h */ |
@ -0,0 +1,296 @@
|
||||
//
|
||||
// BMKLocationManager.h
|
||||
// BMKLocationKit
|
||||
//
|
||||
// Created by baidu on 2017/3/2.
|
||||
// Copyright © 2017年 baidu. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Availability.h> |
||||
#import <Foundation/Foundation.h> |
||||
#import <CoreLocation/CoreLocation.h> |
||||
#import "BMKLocationReGeocode.h" |
||||
#import "BMKLocation.h" |
||||
|
||||
/** BMKLocationCoordinateType 枚举坐标系类型
|
||||
* |
||||
*/ |
||||
typedef NS_ENUM(NSUInteger, BMKLocationCoordinateType) |
||||
{ |
||||
BMKLocationCoordinateTypeBMK09LL = 0, ///<BMK09LL
|
||||
BMKLocationCoordinateTypeBMK09MC, ///<BMK09MC
|
||||
BMKLocationCoordinateTypeWGS84, ///<WGS84
|
||||
BMKLocationCoordinateTypeGCJ02 ///<GCJ02
|
||||
}; |
||||
|
||||
/** BMKLocationNetworkState 枚举识别网络状态类型
|
||||
* |
||||
*/ |
||||
typedef NS_ENUM(int, BMKLocationNetworkState) { |
||||
BMKLocationNetworkStateUnknown = 0, ///<网络状态未知
|
||||
BMKLocationNetworkStateWifi, ///<网络状态wifi
|
||||
BMKLocationNetworkStateWifiHotSpot, ///<网络状态连接WIFI移动热点
|
||||
BMKLocationNetworkStateMobile2G, ///<网络状态移动2G
|
||||
BMKLocationNetworkStateMobile3G, ///<网络状态移动3G
|
||||
BMKLocationNetworkStateMobile4G ///<网络状态移动4G
|
||||
|
||||
}; |
||||
|
||||
|
||||
///BMKLocation errorDomain
|
||||
|
||||
FOUNDATION_EXPORT NSErrorDomain const _Nonnull BMKLocationErrorDomain; |
||||
|
||||
///BMKLocation errorCode
|
||||
typedef NS_ENUM(NSInteger, BMKLocationErrorCode) |
||||
{ |
||||
BMKLocationErrorUnKnown = 0, ///<未知异常
|
||||
BMKLocationErrorLocFailed = 1, ///<位置未知,持续定位中
|
||||
BMKLocationErrorDenied = 2, ///<手机不允许定位,请确认用户授予定位权限或者手机是否打开定位开关
|
||||
BMKLocationErrorNetWork = 3, ///<因为网络原因导致系统定位失败
|
||||
BMKLocationErrorHeadingFailed = 4, ///<获取手机方向信息失败
|
||||
BMKLocationErrorGetExtraNetworkFailed = 5, ///<网络原因导致获取额外信息(地址、网络状态等信息)失败
|
||||
BMKLocationErrorGetExtraParseFailed = 6, ///<网络返回数据解析失败导致获取额外信息(地址、网络状态等信息)失败
|
||||
BMKLocationErrorFailureAuth = 7, ///<鉴权失败导致无法返回定位、地址等信息
|
||||
}; |
||||
|
||||
/** BMKLAccuracyAuthorization 枚举返回定位精度等级
|
||||
* |
||||
*/ |
||||
typedef NS_ENUM(NSInteger, BMKLAccuracyAuthorization) { |
||||
|
||||
BMKLAccuracyAuthorizationFullAccuracy, ///<全量定位精度等级,该等级下定位返回结果会尽可能精准
|
||||
BMKLAccuracyAuthorizationReducedAccuracy, ///<降级定位精度等级,该等级下定位会返回大概5km精度范围的点,定位频率、实时性上也会变慢,比如可能是20分钟之前的点,适用于那些只要求城市级别精度的app使用;ios14之后,该等级受用户控制,需要高等级权限的app需要对应做好适配工作
|
||||
}; |
||||
|
||||
|
||||
/**
|
||||
* @brief 单次定位返回Block |
||||
* @param location 定位信息,数据包括CLLocation 位置数据,BMKLocationReGeocode 地址信息,参考BMKLocation。 |
||||
* @param state 移动热点状态 |
||||
* @param error 错误信息,参考 BMKLocationErrorCode |
||||
*/ |
||||
typedef void (^BMKLocatingCompletionBlock)(BMKLocation * _Nullable location, BMKLocationNetworkState state , NSError * _Nullable error); |
||||
|
||||
|
||||
|
||||
@protocol BMKLocationManagerDelegate; |
||||
|
||||
#pragma mark - BMKLocationManager |
||||
|
||||
|
||||
///BMKLocationManager类。初始化之前请设置 BMKLocationAuth 中的APIKey,否则将无法正常使用服务.
|
||||
@interface BMKLocationManager : NSObject |
||||
|
||||
///实现了 BMKLocationManagerDelegate 协议的类指针。
|
||||
@property (nonatomic, weak, nullable) id<BMKLocationManagerDelegate> delegate; |
||||
|
||||
///设定定位的最小更新距离。默认为 kCLDistanceFilterNone。
|
||||
@property(nonatomic, assign) CLLocationDistance distanceFilter; |
||||
|
||||
///设定定位精度。默认为 kCLLocationAccuracyBest。
|
||||
@property(nonatomic, assign) CLLocationAccuracy desiredAccuracy; |
||||
|
||||
///设定定位类型。默认为 CLActivityTypeAutomotiveNavigation。
|
||||
@property(nonatomic, assign) CLActivityType activityType; |
||||
|
||||
///设定定位坐标系类型。默认为 BMKLocationCoordinateTypeGCJ02。
|
||||
@property(nonatomic, assign) BMKLocationCoordinateType coordinateType; |
||||
|
||||
///指定定位是否会被系统自动暂停。默认为NO。
|
||||
@property(nonatomic, assign) BOOL pausesLocationUpdatesAutomatically; |
||||
|
||||
|
||||
///是否允许后台定位。默认为NO。只在iOS 9.0及之后起作用。设置为YES的时候必须保证 Background Modes 中的 Location updates 处于选中状态,否则会抛出异常。由于iOS系统限制,需要在定位未开始之前或定位停止之后,修改该属性的值才会有效果。
|
||||
@property(nonatomic, assign) BOOL allowsBackgroundLocationUpdates; |
||||
|
||||
///指定单次定位超时时间,默认为10s。最小值是2s。注意单次定位请求前设置。注意: 单次定位超时时间从确定了定位权限(非kCLAuthorizationStatusNotDetermined状态)后开始计算。
|
||||
@property(nonatomic, assign) NSInteger locationTimeout; |
||||
|
||||
///指定单次定位逆地理超时时间,默认为10s。最小值是2s。注意单次定位请求前设置。
|
||||
@property(nonatomic, assign) NSInteger reGeocodeTimeout; |
||||
|
||||
///连续定位是否返回逆地理信息,默认YES。
|
||||
@property (nonatomic, assign) BOOL locatingWithReGeocode; |
||||
|
||||
///定位sdk-v1.3之后,开发者可以选择是否需要最新版本rgc数据,1.9之后默认是需要YES;YES的情况下,定位sdk会实时返回最新的rgc数据,如城市变更等数据都会实时更新
|
||||
@property (nonatomic, assign) BOOL isNeedNewVersionReGeocode; |
||||
|
||||
|
||||
///开发者可以指定该用户的id,用于后续统一识别用户,便于查找问题
|
||||
@property(nonatomic, copy, nullable) NSString * userID; |
||||
|
||||
///返回定位精度等级,IOS14之后用户可以直接控制返回定位的精度等级,开发者可以通过这个值适配不同定位等级下的产品逻辑
|
||||
@property (nonatomic, readonly) BMKLAccuracyAuthorization accuracyAuthorization; |
||||
|
||||
|
||||
/**
|
||||
* @brief 单次定位。如果当前正在连续定位,调用此方法将会失败,返回NO。\n该方法将会根据设定的 desiredAccuracy 去获取定位信息。如果获取的定位信息精确度低于 desiredAccuracy ,将会持续的等待定位信息,直到超时后通过completionBlock返回精度最高的定位信息。\n可以通过 stopUpdatingLocation 方法去取消正在进行的单次定位请求。 |
||||
* @param withReGeocode 是否带有逆地理信息(获取逆地理信息需要联网) |
||||
* @param withNetWorkState 是否带有移动热点识别状态(需要联网) |
||||
* @param completionBlock 单次定位完成后的Block |
||||
* @return 是否成功添加单次定位Request |
||||
*/ |
||||
- (BOOL)requestLocationWithReGeocode:(BOOL)withReGeocode withNetworkState:(BOOL)withNetWorkState completionBlock:(BMKLocatingCompletionBlock _Nonnull)completionBlock; |
||||
|
||||
/**
|
||||
* @brief 开始连续定位。调用此方法会cancel掉所有的单次定位请求。 |
||||
*/ |
||||
- (void)startUpdatingLocation; |
||||
|
||||
/**
|
||||
* @brief 停止连续定位。调用此方法会cancel掉所有的单次定位请求,可以用来取消单次定位。 |
||||
*/ |
||||
- (void)stopUpdatingLocation; |
||||
|
||||
/**
|
||||
* @brief 请求网络状态结果回调。 |
||||
*/ |
||||
- (void)requestNetworkState; |
||||
|
||||
|
||||
/**
|
||||
* @brief 该方法返回设备是否支持设备朝向事件回调。 |
||||
* @return 是否支持设备朝向事件回调 |
||||
*/ |
||||
+ (BOOL)headingAvailable; |
||||
|
||||
/**
|
||||
* @brief 该方法为BMKLocationManager开始设备朝向事件回调。 |
||||
*/ |
||||
- (void)startUpdatingHeading; |
||||
|
||||
/**
|
||||
* @brief 该方法为BMKLocationManager停止设备朝向事件回调。 |
||||
*/ |
||||
- (void)stopUpdatingHeading; |
||||
|
||||
/**
|
||||
* @brief 该方法为BMKLocationManager尝试使用高精度室内定位。在特定的室内场景下会有更高精度的定位回调,只在室内定位版本生效。 |
||||
*/ |
||||
- (void)tryIndoorLocation; |
||||
|
||||
/**
|
||||
* @brief 该方法为BMKLocationManager会关闭高精度室内定位,只在室内定位版本生效。 |
||||
*/ |
||||
- (void)stopIndoorLocation; |
||||
|
||||
|
||||
/**
|
||||
* @brief 转换为百度经纬度的坐标 |
||||
* @param coordinate 待转换的经纬度 |
||||
* @param srctype 待转换坐标系类型 |
||||
* @param destype 目标百度坐标系类型(bd09ll,bd09mc) |
||||
* @return 目标百度坐标系经纬度 |
||||
*/ |
||||
+ (CLLocationCoordinate2D) BMKLocationCoordinateConvert:(CLLocationCoordinate2D) coordinate SrcType:(BMKLocationCoordinateType)srctype DesType:(BMKLocationCoordinateType)destype; |
||||
|
||||
/**
|
||||
* @brief 判断目标经纬度是否在大陆以及港、澳地区。 |
||||
* @param coordinate 待判断的目标经纬度 |
||||
* @param coortype 待判断经纬度的坐标系类型 |
||||
* @return 是否在大陆以及港、澳地区 |
||||
*/ |
||||
+ (BOOL) BMKLocationDataAvailableForCoordinate:(CLLocationCoordinate2D)coordinate withCoorType:(BMKLocationCoordinateType)coortype; |
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief 返回当前定位权限 |
||||
* @return CLAuthorizationStatus 定位权限枚举类型 |
||||
*/ |
||||
- (CLAuthorizationStatus)authorizationStatus; |
||||
|
||||
|
||||
/**
|
||||
* @brief 如果你没有全量定位等级精度权限,利用该接口可以临时请求一次全量定位精度等级,系统会抛出弹框让用户确认是否授权app授予相应权限 |
||||
* @param purposeKey info.plist中NSLocationTemporaryUsageDescriptionDictionary定义的key,对应相应的value可以详细描述申请全量定位精度等级的原因 |
||||
* @param completion 回调是否 |
||||
* @return |
||||
*/ |
||||
- (void)requestTemporaryFullAccuracyAuthorizationWithPurposeKey:(NSString * _Nonnull)purposeKey completion:(void(^ _Nullable)(NSError * _Nullable))completion API_AVAILABLE(ios(14.0)); |
||||
|
||||
/**
|
||||
* @brief 请求一次全量定位精度等级 |
||||
* @param purposeKey info.plist中NSLocationTemporaryUsageDescriptionDictionary定义的key |
||||
* @return |
||||
*/ |
||||
- (void)requestTemporaryFullAccuracyAuthorizationWithPurposeKey:(NSString * _Nonnull)purposeKey API_AVAILABLE(ios(14.0)); |
||||
|
||||
|
||||
@end |
||||
|
||||
#pragma mark - BMKLocationManagerDelegate |
||||
|
||||
|
||||
///BMKLocationManagerDelegate 协议定义了发生错误时的错误回调方法,连续定位的回调方法等。
|
||||
@protocol BMKLocationManagerDelegate <NSObject> |
||||
|
||||
@optional |
||||
|
||||
/**
|
||||
* @brief 为了适配app store关于新的后台定位的审核机制(app store要求如果开发者只配置了使用期间定位,则代码中不能出现申请后台定位的逻辑),当开发者在plist配置NSLocationAlwaysUsageDescription或者NSLocationAlwaysAndWhenInUseUsageDescription时,需要在该delegate中调用后台定位api:[locationManager requestAlwaysAuthorization]。开发者如果只配置了NSLocationWhenInUseUsageDescription,且只有使用期间的定位需求,则无需在delegate中实现逻辑。 |
||||
* @param manager 定位 BMKLocationManager 类。 |
||||
* @param locationManager 系统 CLLocationManager 类 。 |
||||
* @since 1.6.0 |
||||
*/ |
||||
- (void)BMKLocationManager:(BMKLocationManager * _Nonnull)manager doRequestAlwaysAuthorization:(CLLocationManager * _Nonnull)locationManager; |
||||
|
||||
/**
|
||||
* @brief 当定位发生错误时,会调用代理的此方法。 |
||||
* @param manager 定位 BMKLocationManager 类。 |
||||
* @param error 返回的错误,参考 CLError 。 |
||||
*/ |
||||
- (void)BMKLocationManager:(BMKLocationManager * _Nonnull)manager didFailWithError:(NSError * _Nullable)error; |
||||
|
||||
|
||||
/**
|
||||
* @brief 连续定位回调函数。 |
||||
* @param manager 定位 BMKLocationManager 类。 |
||||
* @param location 定位结果,参考BMKLocation。 |
||||
* @param error 错误信息。 |
||||
*/ |
||||
- (void)BMKLocationManager:(BMKLocationManager * _Nonnull)manager didUpdateLocation:(BMKLocation * _Nullable)location orError:(NSError * _Nullable)error; |
||||
|
||||
/**
|
||||
* @brief 定位权限状态改变时回调函数 |
||||
* @param manager 定位 BMKLocationManager 类。 |
||||
* @param status 定位权限状态。 |
||||
*/ |
||||
- (void)BMKLocationManager:(BMKLocationManager * _Nonnull)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status API_DEPRECATED_WITH_REPLACEMENT("-BMKLocationManagerDidChangeAuthorization", ios(4.2, 14.0)); |
||||
|
||||
|
||||
/**
|
||||
* @brief authorizationStatus或者accuracyAuthorization有变化时回调函数 |
||||
* @param manager 定位 BMKLocationManager 类。 |
||||
*/ |
||||
- (void)BMKLocationManagerDidChangeAuthorization:(BMKLocationManager * _Nonnull)manager; |
||||
|
||||
|
||||
/**
|
||||
* @brief 该方法为BMKLocationManager提示需要设备校正回调方法。 |
||||
* @param manager 提供该定位结果的BMKLocationManager类的实例。 |
||||
*/ |
||||
- (BOOL)BMKLocationManagerShouldDisplayHeadingCalibration:(BMKLocationManager * _Nonnull)manager; |
||||
|
||||
/**
|
||||
* @brief 该方法为BMKLocationManager提供设备朝向的回调方法。 |
||||
* @param manager 提供该定位结果的BMKLocationManager类的实例 |
||||
* @param heading 设备的朝向结果 |
||||
*/ |
||||
- (void)BMKLocationManager:(BMKLocationManager * _Nonnull)manager |
||||
didUpdateHeading:(CLHeading * _Nullable)heading; |
||||
|
||||
/**
|
||||
* @brief 该方法为BMKLocationManager所在App系统网络状态改变的回调事件。 |
||||
* @param manager 提供该定位结果的BMKLocationManager类的实例 |
||||
* @param state 当前网络状态 |
||||
* @param error 错误信息 |
||||
*/ |
||||
- (void)BMKLocationManager:(BMKLocationManager * _Nonnull)manager |
||||
didUpdateNetworkState:(BMKLocationNetworkState)state orError:(NSError * _Nullable)error; |
||||
|
||||
|
||||
@end |
||||
|
||||
|
@ -0,0 +1,42 @@
|
||||
//
|
||||
// BMKLocationPoi.h
|
||||
// BMKLocationKit
|
||||
//
|
||||
// Created by baidu on 2017/3/2.
|
||||
// Copyright © 2017年 baidu. All rights reserved.
|
||||
//
|
||||
|
||||
|
||||
///描述Poi各属性
|
||||
@interface BMKLocationPoi : NSObject |
||||
|
||||
///BMKLocationPoi的id属性
|
||||
@property(nonatomic, copy, readonly) NSString *uid; |
||||
|
||||
///BMKLocationPoi的名字属性
|
||||
@property(nonatomic, copy, readonly) NSString *name; |
||||
|
||||
///BMKLocationPoi的标签属性
|
||||
@property(nonatomic, copy, readonly) NSString *tags; |
||||
|
||||
///BMKLocationPoi的地址属性
|
||||
@property(nonatomic, copy, readonly) NSString *addr; |
||||
|
||||
///BMKLocationPoi的可信度
|
||||
@property(nonatomic, assign, readonly) float relaiability; |
||||
|
||||
|
||||
/**
|
||||
* @brief 通过NSDictionary初始化方法一 |
||||
*/ |
||||
- (id)initWithDictionary:(NSDictionary *)dictionary; |
||||
|
||||
|
||||
/**
|
||||
* @brief 通过NSDictionary初始化方法二 |
||||
*/ |
||||
- (id)initWithTwoDictionary:(NSDictionary *)dictionary; |
||||
|
||||
@end |
||||
|
||||
|
@ -0,0 +1,35 @@
|
||||
//
|
||||
// BMKLocationPoiRegion.h
|
||||
// LocationComponent
|
||||
//
|
||||
// Created by Jiang,Fangsheng on 2019/9/4.
|
||||
// Copyright © 2019 baidu. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef BMKLocationPoiRegion_h |
||||
#define BMKLocationPoiRegion_h |
||||
|
||||
|
||||
///描述PoiRegion各属性
|
||||
@interface BMKLocationPoiRegion : NSObject |
||||
|
||||
///BMKLocationPoiRegion的方向属性,如『内』、『外』
|
||||
@property(nonatomic, copy, readonly) NSString *directionDesc; |
||||
|
||||
///BMKLocationPoiRegion的名字属性
|
||||
@property(nonatomic, copy, readonly) NSString *name; |
||||
|
||||
///BMKLocationPoiRegion的标签属性
|
||||
@property(nonatomic, copy, readonly) NSString *tags; |
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief 通过NSDictionary初始化方法一 |
||||
*/ |
||||
- (id)initWithDictionary:(NSDictionary *)dictionary; |
||||
|
||||
|
||||
@end |
||||
|
||||
#endif /* BMKLocationPoiRegion_h */ |
@ -0,0 +1,67 @@
|
||||
//
|
||||
// BMKLocationReGeocode.h
|
||||
// BMKLocationKit
|
||||
//
|
||||
// Created by baidu on 2017/3/2.
|
||||
// Copyright © 2017年 baidu. All rights reserved.
|
||||
//
|
||||
#import <Foundation/Foundation.h> |
||||
#import "BMKLocationPoi.h" |
||||
#import "BMKLocationPoiRegion.h" |
||||
|
||||
///BMKLocationReGeocode类。描述跟地址有关的信息.
|
||||
@interface BMKLocationReGeocode : NSObject |
||||
|
||||
///国家名字属性
|
||||
@property(nonatomic, copy, readonly) NSString *country; |
||||
|
||||
///国家编码属性
|
||||
@property(nonatomic, copy, readonly) NSString *countryCode; |
||||
|
||||
///省份名字属性
|
||||
@property(nonatomic, copy, readonly) NSString *province; |
||||
|
||||
///城市名字属性
|
||||
@property(nonatomic, copy, readonly) NSString *city; |
||||
|
||||
///区名字属性
|
||||
@property(nonatomic, copy, readonly) NSString *district; |
||||
|
||||
///乡镇名字属性
|
||||
@property(nonatomic, copy, readonly) NSString *town; |
||||
|
||||
///街道名字属性
|
||||
@property(nonatomic, copy, readonly) NSString *street; |
||||
|
||||
///街道号码属性
|
||||
@property(nonatomic, copy, readonly) NSString *streetNumber; |
||||
|
||||
///城市编码属性
|
||||
@property(nonatomic, copy, readonly) NSString *cityCode; |
||||
|
||||
///行政区划编码属性
|
||||
@property(nonatomic, copy, readonly) NSString *adCode; |
||||
|
||||
|
||||
///位置语义化结果的定位点在什么地方周围的描述信息
|
||||
@property(nonatomic, copy, readonly) NSString *locationDescribe; |
||||
|
||||
|
||||
///位置语义化结果的属性,该定位点周围的poi列表信息
|
||||
@property(nonatomic, retain, readonly) NSArray<BMKLocationPoi *> *poiList; |
||||
|
||||
///位置语义化结果的定位点在什么地方周围的描述信息
|
||||
@property(nonatomic, strong, readonly) BMKLocationPoiRegion *poiRegion; |
||||
|
||||
/**
|
||||
* @brief 通过NSData初始化方法 |
||||
*/ |
||||
- (id)initWithReGeocodeString:(NSData *)reGeocodeString; |
||||
|
||||
|
||||
/**
|
||||
* @brief 通过JSON初始化方法 |
||||
*/ |
||||
- (id)initWithJsonString:(NSData *)jsonString withHighAccuracy:(BOOL)highAcc; |
||||
|
||||
@end |
@ -0,0 +1,11 @@
|
||||
1、版本: |
||||
百度地图iOS定位SDK v2.0.0 |
||||
|
||||
2、是否带IDFA: |
||||
无 |
||||
|
||||
3、是否为Bitcode: |
||||
是 |
||||
|
||||
4、集成方法: |
||||
http://lbsyun.baidu.com/index.php?title=ios-locsdk |
@ -0,0 +1,141 @@
|
||||
//
|
||||
// BMKGeoFenceManager.h
|
||||
// BMKLocationKit
|
||||
//
|
||||
// Created by baidu on 2017/3/2.
|
||||
// Copyright © 2017年 baidu. All rights reserved.
|
||||
//
|
||||
|
||||
#import "BMKGeoFenceRegion.h" |
||||
|
||||
@protocol BMKGeoFenceManagerDelegate; |
||||
|
||||
///地理围栏监听状态类型
|
||||
typedef NS_OPTIONS(NSUInteger, BMKGeoFenceActiveAction) |
||||
{ |
||||
BMKGeoFenceActiveActionNone = 0, ///< 不进行监听
|
||||
BMKGeoFenceActiveActionInside = 1 << 0, ///< 在范围内
|
||||
BMKGeoFenceActiveActionOutside = 1 << 1, ///< 在范围外
|
||||
BMKGeoFenceActiveActionStayed = 1 << 2, ///< 停留(在范围内超过10分钟)
|
||||
}; |
||||
|
||||
///BMKGeoFence errorDomain
|
||||
FOUNDATION_EXPORT NSErrorDomain const _Nonnull BMKGeoFenceErrorDomain; |
||||
|
||||
///地理围栏错误码
|
||||
typedef NS_ENUM(NSInteger, BMKGeoFenceErrorCode) { |
||||
BMKGeoFenceErrorUnknown = 1, ///< 未知错误
|
||||
BMKGeoFenceErrorInvalidParameter = 2, ///< 参数错误
|
||||
BMKGeoFenceErrorFailureConnection = 3, ///< 网络连接异常
|
||||
BMKGeoFenceErrorFailureAuth = 4, ///< 鉴权失败
|
||||
BMKGeoFenceErrorNoValidFence = 5, ///< 无可用围栏
|
||||
BMKGeoFenceErroFailureLocating = 6, ///< 定位错误
|
||||
}; |
||||
|
||||
|
||||
///地理围栏管理类
|
||||
@interface BMKGeoFenceManager : NSObject |
||||
|
||||
|
||||
///实现了 BMKGeoFenceManagerDelegate 协议的类指针。
|
||||
@property (nonatomic, weak, nullable) id<BMKGeoFenceManagerDelegate> delegate; |
||||
|
||||
|
||||
///需要进行通知的行为,默认为BMKGeoFenceActiveActionInside。
|
||||
@property (nonatomic, assign) BMKGeoFenceActiveAction activeAction; |
||||
|
||||
|
||||
///指定定位是否会被系统自动暂停。默认为NO。
|
||||
@property (nonatomic, assign) BOOL pausesLocationUpdatesAutomatically; |
||||
|
||||
|
||||
///是否允许后台定位。默认为NO。只在iOS 9.0及之后起作用。设置为YES的时候必须保证 Background Modes 中的 Location updates 处于选中状态,否则会抛出异常。
|
||||
@property (nonatomic, assign) BOOL allowsBackgroundLocationUpdates; |
||||
|
||||
|
||||
/**
|
||||
* @brief 添加一个圆形围栏 |
||||
* @param center 围栏的中心点经纬度坐标 |
||||
* @param radius 围栏的半径,单位:米,要求大于0 |
||||
* @param type 围栏的坐标系类型 |
||||
* @param customID 用户自定义ID,可选,SDK原值返回 |
||||
*/ |
||||
- (void)addCircleRegionForMonitoringWithCenter:(CLLocationCoordinate2D)center radius:(CLLocationDistance)radius coorType:(BMKLocationCoordinateType)type customID:(NSString * _Nullable)customID; |
||||
|
||||
|
||||
/**
|
||||
* @brief 根据经纬度坐标数据添加一个闭合的多边形围栏,点与点之间按顺序尾部相连, 第一个点与最后一个点相连 |
||||
* @param coordinates 经纬度坐标点数据,coordinates对应的内存会拷贝,调用者负责该内存的释放 |
||||
* @param count 经纬度坐标点的个数,不可小于3个 |
||||
* @param type 围栏的坐标系类型 |
||||
* @param customID 用户自定义ID,可选,SDK原值返回 |
||||
*/ |
||||
- (void)addPolygonRegionForMonitoringWithCoordinates:(CLLocationCoordinate2D * _Nonnull)coordinates count:(NSInteger)count coorType:(BMKLocationCoordinateType)type customID:(NSString * _Nullable)customID; |
||||
|
||||
|
||||
/**
|
||||
* @brief 根据customID获得指定的围栏,如果customID传nil,则返回全部围栏 |
||||
* @param customID 用户执行添加围栏函数时传入的customID |
||||
* @return 获得的围栏构成的数组,如果没有结果,返回nil |
||||
*/ |
||||
- (NSArray * _Nullable)geoFenceRegionsWithCustomID:(NSString * _Nullable)customID; |
||||
|
||||
|
||||
/**
|
||||
* @brief 移除指定围栏 |
||||
* @param region 要停止监控的围栏 |
||||
*/ |
||||
- (void)removeTheGeoFenceRegion:(BMKGeoFenceRegion * _Nonnull)region; |
||||
|
||||
|
||||
/**
|
||||
* @brief 移除指定customID的围栏 |
||||
* @param customID 用户执行添加围栏函数时传入的customID |
||||
*/ |
||||
- (void)removeGeoFenceRegionsWithCustomID:(NSString * _Nullable)customID; |
||||
|
||||
|
||||
/**
|
||||
* @brief 移除所有围栏 |
||||
*/ |
||||
- (void)removeAllGeoFenceRegions; |
||||
|
||||
|
||||
@end |
||||
|
||||
|
||||
|
||||
///地理围栏代理协议,该协议定义了获取地理围栏相关回调方法,包括添加、状态改变等。
|
||||
@protocol BMKGeoFenceManagerDelegate <NSObject> |
||||
|
||||
@optional |
||||
|
||||
/**
|
||||
* @brief 为了适配app store关于新的后台定位的审核机制(app store要求如果开发者只配置了使用期间定位,则代码中不能出现申请后台定位的逻辑),当开发者在plist配置NSLocationAlwaysUsageDescription或者NSLocationAlwaysAndWhenInUseUsageDescription时,需要在该delegate中调用后台定位api:[locationManager requestAlwaysAuthorization]。开发者如果只配置了NSLocationWhenInUseUsageDescription,且只有使用期间的定位需求,则无需在delegate中实现逻辑。 |
||||
* @param manager 定位 BMKGeoFenceManager 类。 |
||||
* @param locationManager 系统 CLLocationManager 类 。 |
||||
* @since 1.7.0 |
||||
*/ |
||||
- (void)BMKGeoFenceManager:(BMKGeoFenceManager * _Nonnull)manager doRequestAlwaysAuthorization:(CLLocationManager * _Nonnull)locationManager; |
||||
|
||||
/**
|
||||
* @brief 添加地理围栏完成后的回调,成功与失败都会调用 |
||||
* @param manager 地理围栏管理类 |
||||
* @param regions 成功添加的一个或多个地理围栏构成的数组 |
||||
* @param customID 用户执行添加围栏函数时传入的customID |
||||
* @param error 添加失败的错误信息 |
||||
*/ |
||||
- (void)BMKGeoFenceManager:(BMKGeoFenceManager * _Nonnull)manager didAddRegionForMonitoringFinished:(NSArray <BMKGeoFenceRegion *> * _Nullable)regions customID:(NSString * _Nullable)customID error:(NSError * _Nullable)error; |
||||
|
||||
|
||||
/**
|
||||
* @brief 地理围栏状态改变时回调,当围栏状态的值发生改变,定位失败都会调用 |
||||
* @param manager 地理围栏管理类 |
||||
* @param region 状态改变的地理围栏 |
||||
* @param customID 用户执行添加围栏函数时传入的customID |
||||
* @param error 错误信息,如定位相关的错误 |
||||
*/ |
||||
- (void)BMKGeoFenceManager:(BMKGeoFenceManager * _Nonnull)manager didGeoFencesStatusChangedForRegion:(BMKGeoFenceRegion * _Nullable)region customID:(NSString * _Nullable)customID error:(NSError * _Nullable)error; |
||||
|
||||
@end |
||||
|
@ -0,0 +1,114 @@
|
||||
//
|
||||
// BMKGeoFenceRegion.h
|
||||
// BMKLocationKit
|
||||
//
|
||||
// Created by baidu on 2017/3/2.
|
||||
// Copyright © 2017年 baidu. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h> |
||||
#import <CoreLocation/CoreLocation.h> |
||||
#import "BMKLocationManager.h" |
||||
|
||||
///BMKGeoFence Region State
|
||||
typedef NS_ENUM(NSInteger, BMKGeoFenceRegionStatus) |
||||
{ |
||||
BMKGeoFenceRegionStatusUnknown = 0, ///< 未知
|
||||
BMKGeoFenceRegionStatusInside = 1, ///< 在范围内
|
||||
BMKGeoFenceRegionStatusOutside = 1 << 1, ///< 在范围外
|
||||
BMKGeoFenceRegionStatusStayed = 1 << 2, ///< 停留(在范围内超过10分钟)
|
||||
}; |
||||
|
||||
#pragma mark - BMKGeoFenceRegion |
||||
|
||||
|
||||
///地理围栏基类,不可直接使用
|
||||
@interface BMKGeoFenceRegion : NSObject<NSCopying> |
||||
|
||||
|
||||
///BMKGeoFenceRegion的唯一标识符
|
||||
@property (nonatomic, copy, readonly) NSString *identifier; |
||||
|
||||
|
||||
///用户自定义ID,可为nil。
|
||||
@property (nonatomic, copy, readonly) NSString *customID; |
||||
|
||||
|
||||
///坐标点和围栏的关系,比如用户的位置和围栏的关系
|
||||
@property (nonatomic, assign) BMKGeoFenceRegionStatus fenceStatus; |
||||
|
||||
///设定围栏坐标系类型。默认为 BMKLocationCoordinateTypeGCJ02。
|
||||
@property(nonatomic, readonly) BMKLocationCoordinateType coordinateType; |
||||
|
||||
///上次发生状态变化的时间
|
||||
@property(nonatomic, assign)NSTimeInterval lastEventTime; |
||||
|
||||
|
||||
/**
|
||||
* @brief 判断位置与围栏状态 |
||||
* @param CLLocationCoordinate2D 坐标值 |
||||
* @return 返回BMKGeoFenceRegionStatus状态 |
||||
*/ |
||||
-(BMKGeoFenceRegionStatus)judgeStatusWithCoor:(CLLocationCoordinate2D)coor; |
||||
|
||||
@end |
||||
|
||||
|
||||
#pragma mark - BMKLocationCircleRegion |
||||
|
||||
|
||||
///圆形地理围栏
|
||||
@interface BMKGeoFenceCircleRegion : BMKGeoFenceRegion |
||||
|
||||
|
||||
///中心点的经纬度坐标
|
||||
@property (nonatomic, readonly) CLLocationCoordinate2D center; |
||||
|
||||
|
||||
///半径,单位:米
|
||||
@property (nonatomic, readonly) CLLocationDistance radius; |
||||
|
||||
/**
|
||||
* @brief 构造圆形围栏 |
||||
* @param customid 用户自定义ID |
||||
* @param identityid 识别id |
||||
* @param center 中心坐标 |
||||
* @param radius 围栏半径 |
||||
* @param type 坐标系类型 |
||||
* @return BMKGeoFenceCircleRegion id |
||||
*/ |
||||
- (id)initWithCustomID:(NSString *)customid identityID:(NSString *)identityid center:(CLLocationCoordinate2D)center radius:(CLLocationDistance)radius coor:(BMKLocationCoordinateType)type; |
||||
|
||||
|
||||
|
||||
@end |
||||
|
||||
|
||||
#pragma mark -BMKGeoFencePolygonRegion |
||||
|
||||
|
||||
///多边形地理围栏
|
||||
@interface BMKGeoFencePolygonRegion : BMKGeoFenceRegion |
||||
|
||||
|
||||
///经纬度坐标点数据
|
||||
@property (nonatomic, readonly) CLLocationCoordinate2D *coordinates; |
||||
|
||||
|
||||
///经纬度坐标点的个数
|
||||
@property (nonatomic, readonly) NSInteger count; |
||||
|
||||
|
||||
/**
|
||||
* @brief 构造多边形围栏 |
||||
* @param customid 用户自定义ID |
||||
* @param identityid 识别id |
||||
* @param coor 多边形顶点 |
||||
* @param count 顶点个数 |
||||
* @param type 坐标系类型 |
||||
* @return BMKGeoFencePolygonRegion id |
||||
*/ |
||||
- (id)initWithCustomID:(NSString *)customid identityID:(NSString *)identityid coor:(CLLocationCoordinate2D *)coor count:(NSInteger)count coor:(BMKLocationCoordinateType)type; |
||||
|
||||
@end |
||||
|
@ -0,0 +1,97 @@
|
||||
//
|
||||
// BMKLocation.h
|
||||
// LocationComponent
|
||||
//
|
||||
// Created by baidu on 2017/8/16.
|
||||
// Copyright © 2017年 baidu. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef BMKLocation_h |
||||
#define BMKLocation_h |
||||
|
||||
#import <CoreLocation/CoreLocation.h> |
||||
#import "BMKLocationReGeocode.h" |
||||
|
||||
/**
|
||||
* BMKLocationProvider 位置数据来源,分iOS系统定位和其他定位服务结果两种,目前仅支持iOS系统定位服务 |
||||
* |
||||
*/ |
||||
typedef NS_ENUM(int, BMKLocationProvider) { |
||||
|
||||
BMKLocationProviderIOS = 0, //!<位置来源于iOS本身定位
|
||||
BMKLocationProviderOther //!<位置来源于其他定位服务
|
||||
|
||||
}; |
||||
|
||||
///描述百度iOS 定位数据
|
||||
@interface BMKLocation : NSObject |
||||
|
||||
///BMKLocation 位置数据
|
||||
@property(nonatomic, copy, readonly) CLLocation * _Nullable location; |
||||
|
||||
///BMKLocation 地址数据
|
||||
@property(nonatomic, copy) BMKLocationReGeocode * _Nullable rgcData; |
||||
|
||||
///BMKLocation 位置来源
|
||||
@property(nonatomic, assign) BMKLocationProvider provider; |
||||
|
||||
///BMKLocation 位置ID
|
||||
@property(nonatomic, retain) NSString * _Nullable locationID; |
||||
|
||||
/*
|
||||
* floorString |
||||
* |
||||
* Discussion: |
||||
* 室内定位成功时返回的楼层信息,ex:f1 |
||||
*/ |
||||
@property(readonly, nonatomic, copy, nullable) NSString *floorString; |
||||
|
||||
/*
|
||||
* buildingID |
||||
* |
||||
* Discussion: |
||||
* 室内定位成功时返回的百度建筑物ID |
||||
*/ |
||||
@property(readonly, nonatomic, copy, nullable) NSString *buildingID; |
||||
|
||||
/*
|
||||
* buildingName |
||||
* |
||||
* Discussion: |
||||
* 室内定位成功时返回的百度建筑物名称 |
||||
*/ |
||||
@property(readonly, nonatomic, copy, nullable) NSString *buildingName; |
||||
|
||||
|
||||
/*
|
||||
* extraInfo |
||||
* |
||||
* Discussion: |
||||
* 定位附加信息,如停车位code识别结果、停车位code示例、vdr推算结果置信度等 |
||||
*/ |
||||
@property(readonly, nonatomic, copy, nullable) NSDictionary * extraInfo; |
||||
|
||||
/**
|
||||
* @brief 初始化BMKLocation实例 |
||||
* @param loc CLLocation对象 |
||||
* @param rgc BMKLocationReGeocode对象 |
||||
* @return BMKLocation id |
||||
*/ |
||||
- (id _Nonnull)initWithLocation:(CLLocation * _Nullable)loc withRgcData:(BMKLocationReGeocode * _Nullable)rgc; |
||||
|
||||
/**
|
||||
* @brief 构造BMKLocation |
||||
* @param location CLLocation |
||||
* @param floorString 楼层字符串 |
||||
* @param buildingID 建筑物ID |
||||
* @param buildingName 建筑物名称 |
||||
* @param info 位置附加信息 |
||||
* @return BMKLocation id |
||||
*/ |
||||
-(id _Nonnull)initWithLocation:(CLLocation * _Nullable)location floorString:(NSString * _Nullable)floorString buildingID:(NSString * _Nullable)buildingID |
||||
buildingName:(NSString * _Nullable)buildingName extraInfo:(NSDictionary * _Nullable)info withRgcData:(BMKLocationReGeocode * _Nullable)rgc; |
||||
|
||||
|
||||
@end |
||||
|
||||
#endif /* BMKLocation_h */ |
@ -0,0 +1,56 @@
|
||||
//
|
||||
// BMKLocationAuth.h
|
||||
// LocationComponent
|
||||
//
|
||||
// Created by baidu on 2017/4/10.
|
||||
// Copyright © 2017年 baidu. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef BMKLocationAuth_h |
||||
#define BMKLocationAuth_h |
||||
|
||||
///定位鉴权错误码
|
||||
typedef NS_ENUM(NSInteger, BMKLocationAuthErrorCode) { |
||||
BMKLocationAuthErrorUnknown = -1, ///< 未知错误
|
||||
BMKLocationAuthErrorSuccess = 0, ///< 鉴权成功
|
||||
BMKLocationAuthErrorNetworkFailed = 1, ///< 因网络鉴权失败
|
||||
BMKLocationAuthErrorFailed = 2, ///< KEY非法鉴权失败
|
||||
|
||||
}; |
||||
///通知Delegate
|
||||
@protocol BMKLocationAuthDelegate <NSObject> |
||||
@optional |
||||
|
||||
/**
|
||||
*@brief 返回授权验证错误 |
||||
*@param iError 错误号 : 为0时验证通过,具体参加BMKLocationAuthErrorCode |
||||
*/ |
||||
- (void)onCheckPermissionState:(BMKLocationAuthErrorCode)iError; |
||||
@end |
||||
|
||||
|
||||
///BMKLocationAuth类。用于鉴权
|
||||
@interface BMKLocationAuth : NSObject |
||||
|
||||
///鉴权状态0:成功; 1:网络错误; 2:授权失败
|
||||
@property(nonatomic, readonly, assign) BMKLocationAuthErrorCode permisionState; |
||||
|
||||
/**
|
||||
* @brief 得到BMKLocationAuth的单例 |
||||
*/ |
||||
+ (BMKLocationAuth*)sharedInstance; |
||||
|
||||
|
||||
/**
|
||||
*@brief 启动引擎 |
||||
*@param key 申请的有效key |
||||
*@param delegate 回调是否鉴权成功 |
||||
*/ |
||||
-(void)checkPermisionWithKey:(NSString*)key authDelegate:(id<BMKLocationAuthDelegate>)delegate; |
||||
|
||||
|
||||
@end |
||||
|
||||
|
||||
|
||||
#endif /* BMKLocationAuth_h */ |
@ -0,0 +1,16 @@
|
||||
//
|
||||
// BMKLocationComponent.h
|
||||
// LocationComponent
|
||||
//
|
||||
// Created by Baidu on 3/31/14.
|
||||
// Copyright (c) 2014 baidu. All rights reserved.
|
||||
//
|
||||
|
||||
#import "BMKLocationManager.h" |
||||
#import "BMKLocationKitVersion.h" |
||||
#import "BMKLocationPoi.h" |
||||
#import "BMKLocation.h" |
||||
#import "BMKGeoFenceRegion.h" |
||||
#import "BMKGeoFenceManager.h" |
||||
#import "BMKLocationReGeocode.h" |
||||
#import "BMKLocationAuth.h" |
@ -0,0 +1,30 @@
|
||||
//
|
||||
// BMKLocationKitVersion.h
|
||||
// BMKLocationKit
|
||||
//
|
||||
// Created by baidu on 17/9/9.
|
||||
// Copyright © 2017年 baidu. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef BMKLocationKitVersion_h |
||||
#define BMKLocationKitVersion_h |
||||
|
||||
#import <UIKit/UIKit.h> |
||||
|
||||
/**
|
||||
*获取当前定位sdk 的版本号 |
||||
*当前定位sdk版本 : 2.0.0 |
||||
*@return 返回当前定位sdk 的版本号 |
||||
*/ |
||||
UIKIT_EXTERN NSString* BMKLocationKitVersion(); |
||||
|
||||
/**
|
||||
*获取当前定位sdk 的float版本号 |
||||
*当前定位sdk版本 : 2.0 |
||||
*@return 返回当前定位sdk 的float版本号 |
||||
*/ |
||||
UIKIT_EXTERN float BMKLocationKitFloatVersion(); |
||||
|
||||
|
||||
|
||||
#endif /* BMKLocationKitVersion_h */ |
@ -0,0 +1,296 @@
|
||||
//
|
||||
// BMKLocationManager.h
|
||||
// BMKLocationKit
|
||||
//
|
||||
// Created by baidu on 2017/3/2.
|
||||
// Copyright © 2017年 baidu. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Availability.h> |
||||
#import <Foundation/Foundation.h> |
||||
#import <CoreLocation/CoreLocation.h> |
||||
#import "BMKLocationReGeocode.h" |
||||
#import "BMKLocation.h" |
||||
|
||||
/** BMKLocationCoordinateType 枚举坐标系类型
|
||||
* |
||||
*/ |
||||
typedef NS_ENUM(NSUInteger, BMKLocationCoordinateType) |
||||
{ |
||||
BMKLocationCoordinateTypeBMK09LL = 0, ///<BMK09LL
|
||||
BMKLocationCoordinateTypeBMK09MC, ///<BMK09MC
|
||||
BMKLocationCoordinateTypeWGS84, ///<WGS84
|
||||
BMKLocationCoordinateTypeGCJ02 ///<GCJ02
|
||||
}; |
||||
|
||||
/** BMKLocationNetworkState 枚举识别网络状态类型
|
||||
* |
||||
*/ |
||||
typedef NS_ENUM(int, BMKLocationNetworkState) { |
||||
BMKLocationNetworkStateUnknown = 0, ///<网络状态未知
|
||||
BMKLocationNetworkStateWifi, ///<网络状态wifi
|
||||
BMKLocationNetworkStateWifiHotSpot, ///<网络状态连接WIFI移动热点
|
||||
BMKLocationNetworkStateMobile2G, ///<网络状态移动2G
|
||||
BMKLocationNetworkStateMobile3G, ///<网络状态移动3G
|
||||
BMKLocationNetworkStateMobile4G ///<网络状态移动4G
|
||||
|
||||
}; |
||||
|
||||
|
||||
///BMKLocation errorDomain
|
||||
|
||||
FOUNDATION_EXPORT NSErrorDomain const _Nonnull BMKLocationErrorDomain; |
||||
|
||||
///BMKLocation errorCode
|
||||
typedef NS_ENUM(NSInteger, BMKLocationErrorCode) |
||||
{ |
||||
BMKLocationErrorUnKnown = 0, ///<未知异常
|
||||
BMKLocationErrorLocFailed = 1, ///<位置未知,持续定位中
|
||||
BMKLocationErrorDenied = 2, ///<手机不允许定位,请确认用户授予定位权限或者手机是否打开定位开关
|
||||
BMKLocationErrorNetWork = 3, ///<因为网络原因导致系统定位失败
|
||||
BMKLocationErrorHeadingFailed = 4, ///<获取手机方向信息失败
|
||||
BMKLocationErrorGetExtraNetworkFailed = 5, ///<网络原因导致获取额外信息(地址、网络状态等信息)失败
|
||||
BMKLocationErrorGetExtraParseFailed = 6, ///<网络返回数据解析失败导致获取额外信息(地址、网络状态等信息)失败
|
||||
BMKLocationErrorFailureAuth = 7, ///<鉴权失败导致无法返回定位、地址等信息
|
||||
}; |
||||
|
||||
/** BMKLAccuracyAuthorization 枚举返回定位精度等级
|
||||
* |
||||
*/ |
||||
typedef NS_ENUM(NSInteger, BMKLAccuracyAuthorization) { |
||||
|
||||
BMKLAccuracyAuthorizationFullAccuracy, ///<全量定位精度等级,该等级下定位返回结果会尽可能精准
|
||||
BMKLAccuracyAuthorizationReducedAccuracy, ///<降级定位精度等级,该等级下定位会返回大概5km精度范围的点,定位频率、实时性上也会变慢,比如可能是20分钟之前的点,适用于那些只要求城市级别精度的app使用;ios14之后,该等级受用户控制,需要高等级权限的app需要对应做好适配工作
|
||||
}; |
||||
|
||||
|
||||
/**
|
||||
* @brief 单次定位返回Block |
||||
* @param location 定位信息,数据包括CLLocation 位置数据,BMKLocationReGeocode 地址信息,参考BMKLocation。 |
||||
* @param state 移动热点状态 |
||||
* @param error 错误信息,参考 BMKLocationErrorCode |
||||
*/ |
||||
typedef void (^BMKLocatingCompletionBlock)(BMKLocation * _Nullable location, BMKLocationNetworkState state , NSError * _Nullable error); |
||||
|
||||
|
||||
|
||||
@protocol BMKLocationManagerDelegate; |
||||
|
||||
#pragma mark - BMKLocationManager |
||||
|
||||
|
||||
///BMKLocationManager类。初始化之前请设置 BMKLocationAuth 中的APIKey,否则将无法正常使用服务.
|
||||
@interface BMKLocationManager : NSObject |
||||
|
||||
///实现了 BMKLocationManagerDelegate 协议的类指针。
|
||||
@property (nonatomic, weak, nullable) id<BMKLocationManagerDelegate> delegate; |
||||
|
||||
///设定定位的最小更新距离。默认为 kCLDistanceFilterNone。
|
||||
@property(nonatomic, assign) CLLocationDistance distanceFilter; |
||||
|
||||
///设定定位精度。默认为 kCLLocationAccuracyBest。
|
||||
@property(nonatomic, assign) CLLocationAccuracy desiredAccuracy; |
||||
|
||||
///设定定位类型。默认为 CLActivityTypeAutomotiveNavigation。
|
||||
@property(nonatomic, assign) CLActivityType activityType; |
||||
|
||||
///设定定位坐标系类型。默认为 BMKLocationCoordinateTypeGCJ02。
|
||||
@property(nonatomic, assign) BMKLocationCoordinateType coordinateType; |
||||
|
||||
///指定定位是否会被系统自动暂停。默认为NO。
|
||||
@property(nonatomic, assign) BOOL pausesLocationUpdatesAutomatically; |
||||
|
||||
|
||||
///是否允许后台定位。默认为NO。只在iOS 9.0及之后起作用。设置为YES的时候必须保证 Background Modes 中的 Location updates 处于选中状态,否则会抛出异常。由于iOS系统限制,需要在定位未开始之前或定位停止之后,修改该属性的值才会有效果。
|
||||
@property(nonatomic, assign) BOOL allowsBackgroundLocationUpdates; |
||||
|
||||
///指定单次定位超时时间,默认为10s。最小值是2s。注意单次定位请求前设置。注意: 单次定位超时时间从确定了定位权限(非kCLAuthorizationStatusNotDetermined状态)后开始计算。
|
||||
@property(nonatomic, assign) NSInteger locationTimeout; |
||||
|
||||
///指定单次定位逆地理超时时间,默认为10s。最小值是2s。注意单次定位请求前设置。
|
||||
@property(nonatomic, assign) NSInteger reGeocodeTimeout; |
||||
|
||||
///连续定位是否返回逆地理信息,默认YES。
|
||||
@property (nonatomic, assign) BOOL locatingWithReGeocode; |
||||
|
||||
///定位sdk-v1.3之后,开发者可以选择是否需要最新版本rgc数据,1.9之后默认是需要YES;YES的情况下,定位sdk会实时返回最新的rgc数据,如城市变更等数据都会实时更新
|
||||
@property (nonatomic, assign) BOOL isNeedNewVersionReGeocode; |
||||
|
||||
|
||||
///开发者可以指定该用户的id,用于后续统一识别用户,便于查找问题
|
||||
@property(nonatomic, copy, nullable) NSString * userID; |
||||
|
||||
///返回定位精度等级,IOS14之后用户可以直接控制返回定位的精度等级,开发者可以通过这个值适配不同定位等级下的产品逻辑
|
||||
@property (nonatomic, readonly) BMKLAccuracyAuthorization accuracyAuthorization; |
||||
|
||||
|
||||
/**
|
||||
* @brief 单次定位。如果当前正在连续定位,调用此方法将会失败,返回NO。\n该方法将会根据设定的 desiredAccuracy 去获取定位信息。如果获取的定位信息精确度低于 desiredAccuracy ,将会持续的等待定位信息,直到超时后通过completionBlock返回精度最高的定位信息。\n可以通过 stopUpdatingLocation 方法去取消正在进行的单次定位请求。 |
||||
* @param withReGeocode 是否带有逆地理信息(获取逆地理信息需要联网) |
||||
* @param withNetWorkState 是否带有移动热点识别状态(需要联网) |
||||
* @param completionBlock 单次定位完成后的Block |
||||
* @return 是否成功添加单次定位Request |
||||
*/ |
||||
- (BOOL)requestLocationWithReGeocode:(BOOL)withReGeocode withNetworkState:(BOOL)withNetWorkState completionBlock:(BMKLocatingCompletionBlock _Nonnull)completionBlock; |
||||
|
||||
/**
|
||||
* @brief 开始连续定位。调用此方法会cancel掉所有的单次定位请求。 |
||||
*/ |
||||
- (void)startUpdatingLocation; |
||||
|
||||
/**
|
||||
* @brief 停止连续定位。调用此方法会cancel掉所有的单次定位请求,可以用来取消单次定位。 |
||||
*/ |
||||
- (void)stopUpdatingLocation; |
||||
|
||||
/**
|
||||
* @brief 请求网络状态结果回调。 |
||||
*/ |
||||
- (void)requestNetworkState; |
||||
|
||||
|
||||
/**
|
||||
* @brief 该方法返回设备是否支持设备朝向事件回调。 |
||||
* @return 是否支持设备朝向事件回调 |
||||
*/ |
||||
+ (BOOL)headingAvailable; |
||||
|
||||
/**
|
||||
* @brief 该方法为BMKLocationManager开始设备朝向事件回调。 |
||||
*/ |
||||
- (void)startUpdatingHeading; |
||||
|
||||
/**
|
||||
* @brief 该方法为BMKLocationManager停止设备朝向事件回调。 |
||||
*/ |
||||
- (void)stopUpdatingHeading; |
||||
|
||||
/**
|
||||
* @brief 该方法为BMKLocationManager尝试使用高精度室内定位。在特定的室内场景下会有更高精度的定位回调,只在室内定位版本生效。 |
||||
*/ |
||||
- (void)tryIndoorLocation; |
||||
|
||||
/**
|
||||
* @brief 该方法为BMKLocationManager会关闭高精度室内定位,只在室内定位版本生效。 |
||||
*/ |
||||
- (void)stopIndoorLocation; |
||||
|
||||
|
||||
/**
|
||||
* @brief 转换为百度经纬度的坐标 |
||||
* @param coordinate 待转换的经纬度 |
||||
* @param srctype 待转换坐标系类型 |
||||
* @param destype 目标百度坐标系类型(bd09ll,bd09mc) |
||||
* @return 目标百度坐标系经纬度 |
||||
*/ |
||||
+ (CLLocationCoordinate2D) BMKLocationCoordinateConvert:(CLLocationCoordinate2D) coordinate SrcType:(BMKLocationCoordinateType)srctype DesType:(BMKLocationCoordinateType)destype; |
||||
|
||||
/**
|
||||
* @brief 判断目标经纬度是否在大陆以及港、澳地区。 |
||||
* @param coordinate 待判断的目标经纬度 |
||||
* @param coortype 待判断经纬度的坐标系类型 |
||||
* @return 是否在大陆以及港、澳地区 |
||||
*/ |
||||
+ (BOOL) BMKLocationDataAvailableForCoordinate:(CLLocationCoordinate2D)coordinate withCoorType:(BMKLocationCoordinateType)coortype; |
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief 返回当前定位权限 |
||||
* @return CLAuthorizationStatus 定位权限枚举类型 |
||||
*/ |
||||
- (CLAuthorizationStatus)authorizationStatus; |
||||
|
||||
|
||||
/**
|
||||
* @brief 如果你没有全量定位等级精度权限,利用该接口可以临时请求一次全量定位精度等级,系统会抛出弹框让用户确认是否授权app授予相应权限 |
||||
* @param purposeKey info.plist中NSLocationTemporaryUsageDescriptionDictionary定义的key,对应相应的value可以详细描述申请全量定位精度等级的原因 |
||||
* @param completion 回调是否 |
||||
* @return |
||||
*/ |
||||
- (void)requestTemporaryFullAccuracyAuthorizationWithPurposeKey:(NSString * _Nonnull)purposeKey completion:(void(^ _Nullable)(NSError * _Nullable))completion API_AVAILABLE(ios(14.0)); |
||||
|
||||
/**
|
||||
* @brief 请求一次全量定位精度等级 |
||||
* @param purposeKey info.plist中NSLocationTemporaryUsageDescriptionDictionary定义的key |
||||
* @return |
||||
*/ |
||||
- (void)requestTemporaryFullAccuracyAuthorizationWithPurposeKey:(NSString * _Nonnull)purposeKey API_AVAILABLE(ios(14.0)); |
||||
|
||||
|
||||
@end |
||||
|
||||
#pragma mark - BMKLocationManagerDelegate |
||||
|
||||
|
||||
///BMKLocationManagerDelegate 协议定义了发生错误时的错误回调方法,连续定位的回调方法等。
|
||||
@protocol BMKLocationManagerDelegate <NSObject> |
||||
|
||||
@optional |
||||
|
||||
/**
|
||||
* @brief 为了适配app store关于新的后台定位的审核机制(app store要求如果开发者只配置了使用期间定位,则代码中不能出现申请后台定位的逻辑),当开发者在plist配置NSLocationAlwaysUsageDescription或者NSLocationAlwaysAndWhenInUseUsageDescription时,需要在该delegate中调用后台定位api:[locationManager requestAlwaysAuthorization]。开发者如果只配置了NSLocationWhenInUseUsageDescription,且只有使用期间的定位需求,则无需在delegate中实现逻辑。 |
||||
* @param manager 定位 BMKLocationManager 类。 |
||||
* @param locationManager 系统 CLLocationManager 类 。 |
||||
* @since 1.6.0 |
||||
*/ |
||||
- (void)BMKLocationManager:(BMKLocationManager * _Nonnull)manager doRequestAlwaysAuthorization:(CLLocationManager * _Nonnull)locationManager; |
||||
|
||||
/**
|
||||
* @brief 当定位发生错误时,会调用代理的此方法。 |
||||
* @param manager 定位 BMKLocationManager 类。 |
||||
* @param error 返回的错误,参考 CLError 。 |
||||
*/ |
||||
- (void)BMKLocationManager:(BMKLocationManager * _Nonnull)manager didFailWithError:(NSError * _Nullable)error; |
||||
|
||||
|
||||
/**
|
||||
* @brief 连续定位回调函数。 |
||||
* @param manager 定位 BMKLocationManager 类。 |
||||
* @param location 定位结果,参考BMKLocation。 |
||||
* @param error 错误信息。 |
||||
*/ |
||||
- (void)BMKLocationManager:(BMKLocationManager * _Nonnull)manager didUpdateLocation:(BMKLocation * _Nullable)location orError:(NSError * _Nullable)error; |
||||
|
||||
/**
|
||||
* @brief 定位权限状态改变时回调函数 |
||||
* @param manager 定位 BMKLocationManager 类。 |
||||
* @param status 定位权限状态。 |
||||
*/ |
||||
- (void)BMKLocationManager:(BMKLocationManager * _Nonnull)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status API_DEPRECATED_WITH_REPLACEMENT("-BMKLocationManagerDidChangeAuthorization", ios(4.2, 14.0)); |
||||
|
||||
|
||||
/**
|
||||
* @brief authorizationStatus或者accuracyAuthorization有变化时回调函数 |
||||
* @param manager 定位 BMKLocationManager 类。 |
||||
*/ |
||||
- (void)BMKLocationManagerDidChangeAuthorization:(BMKLocationManager * _Nonnull)manager; |
||||
|
||||
|
||||
/**
|
||||
* @brief 该方法为BMKLocationManager提示需要设备校正回调方法。 |
||||
* @param manager 提供该定位结果的BMKLocationManager类的实例。 |
||||
*/ |
||||
- (BOOL)BMKLocationManagerShouldDisplayHeadingCalibration:(BMKLocationManager * _Nonnull)manager; |
||||
|
||||
/**
|
||||
* @brief 该方法为BMKLocationManager提供设备朝向的回调方法。 |
||||
* @param manager 提供该定位结果的BMKLocationManager类的实例 |
||||
* @param heading 设备的朝向结果 |
||||
*/ |
||||
- (void)BMKLocationManager:(BMKLocationManager * _Nonnull)manager |
||||
didUpdateHeading:(CLHeading * _Nullable)heading; |
||||
|
||||
/**
|
||||
* @brief 该方法为BMKLocationManager所在App系统网络状态改变的回调事件。 |
||||
* @param manager 提供该定位结果的BMKLocationManager类的实例 |
||||
* @param state 当前网络状态 |
||||
* @param error 错误信息 |
||||
*/ |
||||
- (void)BMKLocationManager:(BMKLocationManager * _Nonnull)manager |
||||
didUpdateNetworkState:(BMKLocationNetworkState)state orError:(NSError * _Nullable)error; |
||||
|
||||
|
||||
@end |
||||
|
||||
|
@ -0,0 +1,42 @@
|
||||
//
|
||||
// BMKLocationPoi.h
|
||||
// BMKLocationKit
|
||||
//
|
||||
// Created by baidu on 2017/3/2.
|
||||
// Copyright © 2017年 baidu. All rights reserved.
|
||||
//
|
||||
|
||||
|
||||
///描述Poi各属性
|
||||
@interface BMKLocationPoi : NSObject |
||||
|
||||
///BMKLocationPoi的id属性
|
||||
@property(nonatomic, copy, readonly) NSString *uid; |
||||
|
||||
///BMKLocationPoi的名字属性
|
||||
@property(nonatomic, copy, readonly) NSString *name; |
||||
|
||||
///BMKLocationPoi的标签属性
|
||||
@property(nonatomic, copy, readonly) NSString *tags; |
||||
|
||||
///BMKLocationPoi的地址属性
|
||||
@property(nonatomic, copy, readonly) NSString *addr; |
||||
|
||||
///BMKLocationPoi的可信度
|
||||
@property(nonatomic, assign, readonly) float relaiability; |
||||
|
||||
|
||||
/**
|
||||
* @brief 通过NSDictionary初始化方法一 |
||||
*/ |
||||
- (id)initWithDictionary:(NSDictionary *)dictionary; |
||||
|
||||
|
||||
/**
|
||||
* @brief 通过NSDictionary初始化方法二 |
||||
*/ |
||||
- (id)initWithTwoDictionary:(NSDictionary *)dictionary; |
||||
|
||||
@end |
||||
|
||||
|
@ -0,0 +1,35 @@
|
||||
//
|
||||
// BMKLocationPoiRegion.h
|
||||
// LocationComponent
|
||||
//
|
||||
// Created by Jiang,Fangsheng on 2019/9/4.
|
||||
// Copyright © 2019 baidu. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef BMKLocationPoiRegion_h |
||||
#define BMKLocationPoiRegion_h |
||||
|
||||
|
||||
///描述PoiRegion各属性
|
||||
@interface BMKLocationPoiRegion : NSObject |
||||
|
||||
///BMKLocationPoiRegion的方向属性,如『内』、『外』
|
||||
@property(nonatomic, copy, readonly) NSString *directionDesc; |
||||
|
||||
///BMKLocationPoiRegion的名字属性
|
||||
@property(nonatomic, copy, readonly) NSString *name; |
||||
|
||||
///BMKLocationPoiRegion的标签属性
|
||||
@property(nonatomic, copy, readonly) NSString *tags; |
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief 通过NSDictionary初始化方法一 |
||||
*/ |
||||
- (id)initWithDictionary:(NSDictionary *)dictionary; |
||||
|
||||
|
||||
@end |
||||
|
||||
#endif /* BMKLocationPoiRegion_h */ |
@ -0,0 +1,67 @@
|
||||
//
|
||||
// BMKLocationReGeocode.h
|
||||
// BMKLocationKit
|
||||
//
|
||||
// Created by baidu on 2017/3/2.
|
||||
// Copyright © 2017年 baidu. All rights reserved.
|
||||
//
|
||||
#import <Foundation/Foundation.h> |
||||
#import "BMKLocationPoi.h" |
||||
#import "BMKLocationPoiRegion.h" |
||||
|
||||
///BMKLocationReGeocode类。描述跟地址有关的信息.
|
||||
@interface BMKLocationReGeocode : NSObject |
||||
|
||||
///国家名字属性
|
||||
@property(nonatomic, copy, readonly) NSString *country; |
||||
|
||||
///国家编码属性
|
||||
@property(nonatomic, copy, readonly) NSString *countryCode; |
||||
|
||||
///省份名字属性
|
||||
@property(nonatomic, copy, readonly) NSString *province; |
||||
|
||||
///城市名字属性
|
||||
@property(nonatomic, copy, readonly) NSString *city; |
||||
|
||||
///区名字属性
|
||||
@property(nonatomic, copy, readonly) NSString *district; |
||||
|
||||
///乡镇名字属性
|
||||
@property(nonatomic, copy, readonly) NSString *town; |
||||
|
||||
///街道名字属性
|
||||
@property(nonatomic, copy, readonly) NSString *street; |
||||
|
||||
///街道号码属性
|
||||
@property(nonatomic, copy, readonly) NSString *streetNumber; |
||||
|
||||
///城市编码属性
|
||||
@property(nonatomic, copy, readonly) NSString *cityCode; |
||||
|
||||
///行政区划编码属性
|
||||
@property(nonatomic, copy, readonly) NSString *adCode; |
||||
|
||||
|
||||
///位置语义化结果的定位点在什么地方周围的描述信息
|
||||
@property(nonatomic, copy, readonly) NSString *locationDescribe; |
||||
|
||||
|
||||
///位置语义化结果的属性,该定位点周围的poi列表信息
|
||||
@property(nonatomic, retain, readonly) NSArray<BMKLocationPoi *> *poiList; |
||||
|
||||
///位置语义化结果的定位点在什么地方周围的描述信息
|
||||
@property(nonatomic, strong, readonly) BMKLocationPoiRegion *poiRegion; |
||||
|
||||
/**
|
||||
* @brief 通过NSData初始化方法 |
||||
*/ |
||||
- (id)initWithReGeocodeString:(NSData *)reGeocodeString; |
||||
|
||||
|
||||
/**
|
||||
* @brief 通过JSON初始化方法 |
||||
*/ |
||||
- (id)initWithJsonString:(NSData *)jsonString withHighAccuracy:(BOOL)highAcc; |
||||
|
||||
@end |
Loading…
Reference in new issue