##LH_CLLocationManager.h的封装 -1 具体功能
/**
* 定位管理者对象
*
* @return 创建好的定位管理者对象
*/
+ (LH_CLLocationManager *)shareLocation;
/**
* 用于获取用户当前位置的block
*
* @param locaiontBlock 返回的用户当前位置的Corrrdinate
*/
- (void) lh_getCurrentLocationCoordinate:(LocationCorrrdinateBlock) locationtBlock;
/**
* 获取定位到的城市的经纬度和详细地址
*
* @param locaiontBlock 返回定位代码块
* @param addressBlock 返回详细地址代码块
*/
- (void) lh_getCurrentLocationCoordinate:(LocationCorrrdinateBlock) locationtBlock withAddress:(NSStringDetailAddressBlock) addressBlock;
/**
* 获取详细地址
*
* @param addressBlock addressBlock description
*/
- (void)lh_getCurrentDetailAddress:(NSStringDetailAddressBlock)addressBlock;
/**
* 获取当前定位到所在国家
*
* @param countryBlock 返回定位到所在国家代码块
*/
- (void)lh_getCurrentCountry:(NSStringCountryBlock)countryBlock;
/**
* 获取城市的省份
*
* @param cityBlock 返回所在省份的block
*/
- (void)lh_getCurrentProvince:(NSStringProvinceBlock)provinceBlock;
/**
* 获取所在城市
*
* @param cityBlock 返回所在城市的block
*/
-(void)lh_getCurrentCity:(NSStringCityBlock)cityBlock;
/**
* 获取所在城市的街道名
*
* @param thoroughfareBlock 返回所在街道的block
*/
-(void)lh_getCurrentThoroughfare:(NSStringThoroughfareBlock)thoroughfareBlock;
/**
* 获取邮编
*
* @param postalCode 邮编block
*/
-(void)lh_getCurrentPostalCode:(NSStringPostalCodeBlock)postalCode;
/**
* 定位失败回调的block
*
* @param errorBlock errorBlock 错误代码块
*/
- (void)lh_getLocationError:(LocationErrorBlock) errorBlock;
-2 使用方法
1 -导入头文件“LH_CLLocationManager.h”
2 -实例化定位管理者的对象
LH_CLLocationManager* manger=[LH_CLLocationManager shareLocation];
3 -如果定位成功后,调用block
-3 具体示例
[manger lh_getCurrentCity:^(NSString *cityString) {
NSLog(@"当前城市:%@",cityString);
}];
[manger lh_getCurrentCountry:^(NSString *countryString) {
NSLog(@"当前国家:%@",countryString);
}];
[manger lh_getCurrentProvince:^(NSString *provinceString) {
NSLog(@"当前省份:%@",provinceString);
}];
[manger lh_getCurrentThoroughfare:^(NSString *thoroughfareString) {
NSLog(@"当前街道:%@",thoroughfareString);
}];
[manger lh_getCurrentDetailAddress:^(NSString *detailAddressString) {
NSLog(@"当前详细地址:%@",detailAddressString);
}];
[manger lh_getCurrentPostalCode:^(NSString *postalCodeString) {
NSLog(@"当前邮政编码:%@",postalCodeString);
}];
[manger lh_getCurrentLocationCoordinate:^(CLLocationCoordinate2D locationCorrrdinate) {
NSLog(@"当前位置经纬度(%lf,%lf)",locationCorrrdinate.latitude,locationCorrrdinate.longitude);
}];
[manger lh_getCurrentLocationCoordinate:^(CLLocationCoordinate2D locationCorrrdinate) {
NSLog(@"======当前位置经纬度(%lf,%lf)",locationCorrrdinate.latitude,locationCorrrdinate.longitude);
} withAddress:^(NSString *detailAddressString) {
NSLog(@"------当前详细地址:%@",detailAddressString);
-4 注意点
-5 具体使用请参看代码(如有疑问,欢迎进群479192251讨论,或者博客留言看到会及时回复的)
来源:oschina
链接:https://my.oschina.net/u/2332019/blog/725645