新版本
This commit is contained in:
@@ -9,11 +9,12 @@
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "BaseVIewContorller.h"
|
||||
#import "Utils.h"
|
||||
#import <BaiduMapAPI_Search/BMKSearchComponent.h>
|
||||
//#import <BaiduMapAPI_Search/BMKSearchComponent.h>
|
||||
//#import <BaiduMapAPI_Search/BMKGeocodeSearch.h>
|
||||
|
||||
@interface LogInViewController : BaseVIewContorller
|
||||
{
|
||||
BMKGeoCodeSearch*_geocodesearch;
|
||||
// BMKGeoCodeSearch*_geocodesearch;
|
||||
}
|
||||
@property (weak, nonatomic) IBOutlet UITextField *loginPhoneNumberTextField;
|
||||
@property (weak, nonatomic) IBOutlet UITextField *loginPasswordTextField;
|
||||
|
||||
@@ -37,18 +37,20 @@
|
||||
|
||||
#import "Toast+UIView.h"
|
||||
#import "IfishNewsModel.h"
|
||||
#import <BaiduMapAPI_Location/BMKLocationService.h>
|
||||
#import <BaiduMapAPI_Search/BMKSearchComponent.h>
|
||||
#import <BaiduMapAPI_Utils/BMKUtilsComponent.h>
|
||||
|
||||
//#import <BaiduMapAPI_Location/BMKLocationService.h>
|
||||
//#import <BaiduMapAPI_Search/BMKSearchComponent.h>
|
||||
//#import <BaiduMapAPI_Utils/BMKUtilsComponent.h>
|
||||
#import <CoreLocation/CoreLocation.h>
|
||||
#import "IfishUserDataUnity.h"
|
||||
@interface LogInViewController ()<UITextFieldDelegate,BMKLocationServiceDelegate,BMKGeoCodeSearchDelegate>
|
||||
@interface LogInViewController ()<UITextFieldDelegate,CLLocationManagerDelegate>
|
||||
@property (weak, nonatomic) IBOutlet UIButton *logInButton;
|
||||
@property(nonatomic,strong)UIActivityIndicatorView*indicatorView;
|
||||
@property(nonatomic)BMKLocationService*locService;
|
||||
//@property(nonatomic)BMKLocationService*locService;
|
||||
@property(nonatomic) double longitude;
|
||||
@property(nonatomic) double latitude;
|
||||
@property(nonatomic,copy) NSString *adderss;
|
||||
@property (nonatomic,strong ) CLLocationManager *locationManager;//定位服务
|
||||
@property (nonatomic,copy) NSString *currentCity;//城市
|
||||
@end
|
||||
extern BOOL firstLogIn;
|
||||
BOOL formLogIn;// //连接页面是否来自登录界面初始化
|
||||
@@ -125,22 +127,44 @@
|
||||
#pragma mark 定位
|
||||
-(void)getLocation{
|
||||
//初始化BMKLocationService
|
||||
_locService=[[BMKLocationService alloc]init];
|
||||
_locService.delegate=self;
|
||||
//启动LocationService
|
||||
[_locService startUserLocationService];
|
||||
_geocodesearch=[[BMKGeoCodeSearch alloc]init];
|
||||
// _locService=[[BMKLocationService alloc]init];
|
||||
// _locService.delegate=self;
|
||||
// //启动LocationService
|
||||
// [_locService startUserLocationService];
|
||||
// _geocodesearch=[[BMKGeoCodeSearch alloc]init];
|
||||
if ([CLLocationManager locationServicesEnabled]) {
|
||||
_locationManager = [[CLLocationManager alloc]init];
|
||||
_locationManager.delegate = self;
|
||||
[_locationManager requestAlwaysAuthorization];
|
||||
_currentCity = [[NSString alloc]init];
|
||||
[_locationManager requestWhenInUseAuthorization];
|
||||
_locationManager.desiredAccuracy = kCLLocationAccuracyBest;
|
||||
_locationManager.distanceFilter = 5.0;
|
||||
[_locationManager startUpdatingLocation];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
-(void)viewWillAppear:(BOOL)animated{
|
||||
_geocodesearch.delegate=self;// 此处记得不用的时候需要置nil,否则影响内存的释放
|
||||
_locService.delegate=self;
|
||||
// _geocodesearch.delegate=self;// 此处记得不用的时候需要置nil,否则影响内存的释放
|
||||
// _locService.delegate=self;
|
||||
if ([CLLocationManager locationServicesEnabled]) {
|
||||
_locationManager = [[CLLocationManager alloc]init];
|
||||
_locationManager.delegate = self;
|
||||
[_locationManager requestAlwaysAuthorization];
|
||||
// _currentCity = [[NSString alloc]init];
|
||||
[_locationManager requestWhenInUseAuthorization];
|
||||
_locationManager.desiredAccuracy = kCLLocationAccuracyBest;
|
||||
_locationManager.distanceFilter = 5.0;
|
||||
[_locationManager startUpdatingLocation];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
-(void)viewWillDisappear:(BOOL)animated{
|
||||
|
||||
_locService.delegate=nil;
|
||||
// _locService.delegate=nil;
|
||||
}
|
||||
|
||||
-(void)backItemBtn{
|
||||
@@ -415,63 +439,128 @@
|
||||
}
|
||||
|
||||
//处理方向变更信息
|
||||
- (void)didUpdateUserHeading:(BMKUserLocation *)userLocation
|
||||
{
|
||||
//NSLog(@"heading is %@",userLocation.heading);
|
||||
}
|
||||
//处理位置坐标更新
|
||||
- (void)didUpdateBMKUserLocation:(BMKUserLocation *)userLocation
|
||||
{
|
||||
NSLog(@"didUpdateUserLocation lat %f,long %f",userLocation.location.coordinate.latitude,userLocation.location.coordinate.longitude);
|
||||
self.latitude = userLocation.location.coordinate.latitude;
|
||||
self.longitude = userLocation.location.coordinate.longitude;
|
||||
static dispatch_once_t disOnce;
|
||||
dispatch_once(&disOnce, ^ {
|
||||
|
||||
[self reverseGeoCodeWithlatitude:userLocation.location.coordinate.latitude addlongitude:userLocation.location.coordinate.longitude];
|
||||
});
|
||||
|
||||
}
|
||||
//- (void)didUpdateUserHeading:(BMKUserLocation *)userLocation
|
||||
//{
|
||||
// //NSLog(@"heading is %@",userLocation.heading);
|
||||
//}
|
||||
////处理位置坐标更新
|
||||
//- (void)didUpdateBMKUserLocation:(BMKUserLocation *)userLocation
|
||||
//{
|
||||
// NSLog(@"didUpdateUserLocation lat %f,long %f",userLocation.location.coordinate.latitude,userLocation.location.coordinate.longitude);
|
||||
// self.latitude = userLocation.location.coordinate.latitude;
|
||||
// self.longitude = userLocation.location.coordinate.longitude;
|
||||
// static dispatch_once_t disOnce;
|
||||
// dispatch_once(&disOnce, ^ {
|
||||
//
|
||||
// [self reverseGeoCodeWithlatitude:userLocation.location.coordinate.latitude addlongitude:userLocation.location.coordinate.longitude];
|
||||
// });
|
||||
//
|
||||
//}
|
||||
/**
|
||||
* 地理反编码
|
||||
*/
|
||||
-(void)reverseGeoCodeWithlatitude:(CLLocationDegrees)latitude addlongitude:(CLLocationDegrees)longitude{
|
||||
CLLocationCoordinate2D pt=(CLLocationCoordinate2D){latitude,longitude};
|
||||
BMKReverseGeoCodeOption *reverseGeocodeSearchOption = [[BMKReverseGeoCodeOption alloc]init];
|
||||
reverseGeocodeSearchOption.reverseGeoPoint=pt;
|
||||
BOOL flag = [_geocodesearch reverseGeoCode:reverseGeocodeSearchOption];
|
||||
if(flag)
|
||||
{
|
||||
NSLog(@"反geo检索发送成功");
|
||||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"反geo检索发送失败");
|
||||
}
|
||||
|
||||
}
|
||||
//-(void)reverseGeoCodeWithlatitude:(CLLocationDegrees)latitude addlongitude:(CLLocationDegrees)longitude{
|
||||
// CLLocationCoordinate2D pt=(CLLocationCoordinate2D){latitude,longitude};
|
||||
// BMKReverseGeoCodeOption *reverseGeocodeSearchOption = [[BMKReverseGeoCodeOption alloc]init];
|
||||
// reverseGeocodeSearchOption.reverseGeoPoint=pt;
|
||||
// BOOL flag = [_geocodesearch reverseGeoCode:reverseGeocodeSearchOption];
|
||||
// if(flag)
|
||||
// {
|
||||
// NSLog(@"反geo检索发送成功");
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// NSLog(@"反geo检索发送失败");
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
||||
-(void)dealloc{
|
||||
|
||||
if (_geocodesearch!=nil) {
|
||||
_geocodesearch=nil;
|
||||
}
|
||||
}
|
||||
//-(void)dealloc{
|
||||
//
|
||||
// if (_geocodesearch!=nil) {
|
||||
// _geocodesearch=nil;
|
||||
// }
|
||||
//}
|
||||
|
||||
#pragma mark BMKGeoCodeSearchDelegate
|
||||
-(void)onGetReverseGeoCodeResult:(BMKGeoCodeSearch *)searcher result:(BMKReverseGeoCodeResult *)result errorCode:(BMKSearchErrorCode)error{
|
||||
NSLog(@"address%@",result.address);
|
||||
//-(void)onGetReverseGeoCodeResult:(BMKGeoCodeSearch *)searcher result:(BMKReverseGeoCodeResult *)result errorCode:(BMKSearchErrorCode)error{
|
||||
// NSLog(@"address%@",result.address);
|
||||
//
|
||||
// NSUserDefaults*userdefult=[NSUserDefaults standardUserDefaults];
|
||||
// NSString*address=result.address;
|
||||
// self.adderss = address;
|
||||
// [userdefult setObject:address forKey:@"address"];
|
||||
// [userdefult setDouble:self.latitude forKey:@"userlatitude"];
|
||||
// [userdefult setDouble:self.longitude forKey:@"userlongitude"];
|
||||
// [userdefult synchronize];
|
||||
//
|
||||
// _geocodesearch.delegate=nil;
|
||||
//}
|
||||
|
||||
#pragma mark - 定位失败
|
||||
-(void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error{
|
||||
|
||||
NSUserDefaults*userdefult=[NSUserDefaults standardUserDefaults];
|
||||
NSString*address=result.address;
|
||||
self.adderss = address;
|
||||
[userdefult setObject:address forKey:@"address"];
|
||||
[userdefult setDouble:self.latitude forKey:@"userlatitude"];
|
||||
[userdefult setDouble:self.longitude forKey:@"userlongitude"];
|
||||
[userdefult synchronize];
|
||||
|
||||
_geocodesearch.delegate=nil;
|
||||
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"请在设置中打开定位" preferredStyle:UIAlertControllerStyleAlert];
|
||||
UIAlertAction *ok = [UIAlertAction actionWithTitle:@"打开定位" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
|
||||
NSURL *settingURL = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
|
||||
[[UIApplication sharedApplication]openURL:settingURL];
|
||||
}];
|
||||
UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
|
||||
|
||||
}];
|
||||
[alert addAction:cancel];
|
||||
[alert addAction:ok];
|
||||
[self presentViewController:alert animated:YES completion:nil];
|
||||
}
|
||||
#pragma mark - 定位成功
|
||||
-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray<CLLocation *> *)locations{
|
||||
|
||||
[_locationManager stopUpdatingLocation];
|
||||
CLLocation *currentLocation = [locations lastObject];
|
||||
CLGeocoder *geoCoder = [[CLGeocoder alloc]init];
|
||||
//当前的经纬度
|
||||
NSLog(@"当前的经纬度 %f,%f",currentLocation.coordinate.latitude,currentLocation.coordinate.longitude);
|
||||
self.longitude=currentLocation.coordinate.longitude;
|
||||
self.latitude=currentLocation.coordinate.latitude;
|
||||
//这里的代码是为了判断didUpdateLocations调用了几次 有可能会出现多次调用 为了避免不必要的麻烦 在这里加个if判断 如果大于1.0就return
|
||||
NSTimeInterval locationAge = -[currentLocation.timestamp timeIntervalSinceNow];
|
||||
if (locationAge > 1.0){//如果调用已经一次,不再执行
|
||||
return;
|
||||
}
|
||||
//地理反编码 可以根据坐标(经纬度)确定位置信息(街道 门牌等)
|
||||
[geoCoder reverseGeocodeLocation:currentLocation completionHandler:^(NSArray<CLPlacemark *> * _Nullable placemarks, NSError * _Nullable error) {
|
||||
if (placemarks.count >0) {
|
||||
CLPlacemark *placeMark = placemarks[0];
|
||||
_currentCity = placeMark.locality;
|
||||
if (!_currentCity) {
|
||||
_currentCity = @"无法定位当前城市";
|
||||
}
|
||||
//看需求定义一个全局变量来接收赋值
|
||||
NSLog(@"当前国家 - %@",placeMark.country);//当前国家
|
||||
NSLog(@"当前城市 - %@",_currentCity);//当前城市
|
||||
NSLog(@"当前位置 - %@",placeMark.subLocality);//当前位置
|
||||
NSLog(@"当前街道 - %@",placeMark.thoroughfare);//当前街道
|
||||
NSLog(@"具体地址 - %@",placeMark.name);//具体地址
|
||||
NSString *message = [NSString stringWithFormat:@"%@,%@,%@,%@,%@",placeMark.country,_currentCity,placeMark.subLocality,placeMark.thoroughfare,placeMark.name];
|
||||
NSUserDefaults*userdefult=[NSUserDefaults standardUserDefaults];
|
||||
NSString*address=message;
|
||||
self.adderss = address;
|
||||
[userdefult setObject:address forKey:@"address"];
|
||||
[userdefult setDouble:self.latitude forKey:@"userlatitude"];
|
||||
[userdefult setDouble:self.longitude forKey:@"userlongitude"];
|
||||
[userdefult synchronize];
|
||||
|
||||
}else if (error == nil && placemarks.count){
|
||||
|
||||
NSLog(@"NO location and error return");
|
||||
}else if (error){
|
||||
|
||||
NSLog(@"loction error:%@",error);
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@end
|
||||
|
||||
@@ -10,11 +10,11 @@
|
||||
#import "MBProgressHUD.h"
|
||||
#import "BaseVIewContorller.h"
|
||||
|
||||
#import <BaiduMapAPI_Search/BMKSearchComponent.h>
|
||||
//#import <BaiduMapAPI_Search/BMKSearchComponent.h>
|
||||
|
||||
@interface RegistViewController : UIViewController
|
||||
{
|
||||
BMKGeoCodeSearch*_geocodesearch;
|
||||
// BMKGeoCodeSearch*_geocodesearch;
|
||||
}
|
||||
@property (weak, nonatomic) IBOutlet UITextField *phoneNumberTextField;
|
||||
@property (weak, nonatomic) IBOutlet UITextField *verifyTextField;
|
||||
|
||||
@@ -22,9 +22,9 @@
|
||||
#import "ChatroomModel.h"
|
||||
//#import <RongIMKit/RongIMKit.h>
|
||||
//#import <RongIMLib/RongIMLib.h>
|
||||
#import <BaiduMapAPI_Location/BMKLocationService.h>
|
||||
#import <BaiduMapAPI_Search/BMKSearchComponent.h>
|
||||
#import <BaiduMapAPI_Utils/BMKUtilsComponent.h>
|
||||
//#import <BaiduMapAPI_Location/BMKLocationService.h>
|
||||
//#import <BaiduMapAPI_Search/BMKSearchComponent.h>
|
||||
//#import <BaiduMapAPI_Utils/BMKUtilsComponent.h>
|
||||
//#import "FirstConnectWifiController.h"
|
||||
//#import "SelectDeviceViewController.h"
|
||||
//#import "IfishSelectCardViewController.h"
|
||||
@@ -36,7 +36,8 @@
|
||||
#import <SMS_SDK/SMSSDK.h>
|
||||
#import <SMS_SDK/Extend/SMSSDK+ExtexdMethods.h>
|
||||
#import "XWCountryCodeController.h"
|
||||
@interface RegistViewController ()<UITextFieldDelegate,UIAlertViewDelegate,MBProgressHUDDelegate,BMKLocationServiceDelegate,BMKGeoCodeSearchDelegate>
|
||||
#import <CoreLocation/CoreLocation.h>
|
||||
@interface RegistViewController ()<UITextFieldDelegate,UIAlertViewDelegate,MBProgressHUDDelegate,CLLocationManagerDelegate>
|
||||
{
|
||||
|
||||
BOOL _showed;//显示过了
|
||||
@@ -55,7 +56,9 @@
|
||||
@property(nonatomic,strong)NSMutableArray*deviceArry;
|
||||
@property(nonatomic,strong)UIActivityIndicatorView*indicatorView;
|
||||
|
||||
@property(nonatomic)BMKLocationService*locService;
|
||||
//@property(nonatomic)BMKLocationService*locService;
|
||||
@property (nonatomic,strong ) CLLocationManager *locationManager;//定位服务
|
||||
@property (nonatomic,copy) NSString *currentCity;//城市
|
||||
@property(nonatomic) double longitude;
|
||||
@property(nonatomic) double latitude;
|
||||
@property(nonatomic,copy) NSString *adderss;
|
||||
@@ -102,12 +105,91 @@ extern BOOL formLogIn;
|
||||
#pragma mark 定位
|
||||
-(void)getLocation{
|
||||
//初始化BMKLocationService
|
||||
_locService=[[BMKLocationService alloc]init];
|
||||
_locService.delegate=self;
|
||||
//启动LocationService
|
||||
[_locService startUserLocationService];
|
||||
_geocodesearch=[[BMKGeoCodeSearch alloc]init];
|
||||
// _locService=[[BMKLocationService alloc]init];
|
||||
// _locService.delegate=self;
|
||||
// //启动LocationService
|
||||
// [_locService startUserLocationService];
|
||||
// _geocodesearch=[[BMKGeoCodeSearch alloc]init];
|
||||
if ([CLLocationManager locationServicesEnabled]) {
|
||||
_locationManager = [[CLLocationManager alloc]init];
|
||||
_locationManager.delegate = self;
|
||||
[_locationManager requestAlwaysAuthorization];
|
||||
_currentCity = [[NSString alloc]init];
|
||||
[_locationManager requestWhenInUseAuthorization];
|
||||
_locationManager.desiredAccuracy = kCLLocationAccuracyBest;
|
||||
_locationManager.distanceFilter = 5.0;
|
||||
[_locationManager startUpdatingLocation];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - 定位失败
|
||||
-(void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error{
|
||||
|
||||
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"请在设置中打开定位" preferredStyle:UIAlertControllerStyleAlert];
|
||||
UIAlertAction *ok = [UIAlertAction actionWithTitle:@"打开定位" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
|
||||
NSURL *settingURL = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
|
||||
[[UIApplication sharedApplication]openURL:settingURL];
|
||||
}];
|
||||
UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
|
||||
|
||||
}];
|
||||
[alert addAction:cancel];
|
||||
[alert addAction:ok];
|
||||
[self presentViewController:alert animated:YES completion:nil];
|
||||
}
|
||||
#pragma mark - 定位成功
|
||||
-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray<CLLocation *> *)locations{
|
||||
|
||||
[_locationManager stopUpdatingLocation];
|
||||
CLLocation *currentLocation = [locations lastObject];
|
||||
CLGeocoder *geoCoder = [[CLGeocoder alloc]init];
|
||||
//当前的经纬度
|
||||
NSLog(@"当前的经纬度 %f,%f",currentLocation.coordinate.latitude,currentLocation.coordinate.longitude);
|
||||
self.latitude=currentLocation.coordinate.latitude;
|
||||
self.longitude=currentLocation.coordinate.longitude;
|
||||
//这里的代码是为了判断didUpdateLocations调用了几次 有可能会出现多次调用 为了避免不必要的麻烦 在这里加个if判断 如果大于1.0就return
|
||||
NSTimeInterval locationAge = -[currentLocation.timestamp timeIntervalSinceNow];
|
||||
if (locationAge > 1.0){//如果调用已经一次,不再执行
|
||||
return;
|
||||
}
|
||||
//地理反编码 可以根据坐标(经纬度)确定位置信息(街道 门牌等)
|
||||
[geoCoder reverseGeocodeLocation:currentLocation completionHandler:^(NSArray<CLPlacemark *> * _Nullable placemarks, NSError * _Nullable error) {
|
||||
if (placemarks.count >0) {
|
||||
CLPlacemark *placeMark = placemarks[0];
|
||||
_currentCity = placeMark.locality;
|
||||
if (!_currentCity) {
|
||||
_currentCity = @"无法定位当前城市";
|
||||
}
|
||||
//看需求定义一个全局变量来接收赋值
|
||||
NSLog(@"当前国家 - %@",placeMark.country);//当前国家
|
||||
NSLog(@"当前城市 - %@",_currentCity);//当前城市
|
||||
NSLog(@"当前位置 - %@",placeMark.subLocality);//当前位置
|
||||
NSLog(@"当前街道 - %@",placeMark.thoroughfare);//当前街道
|
||||
NSLog(@"具体地址 - %@",placeMark.name);//具体地址
|
||||
NSString *message = [NSString stringWithFormat:@"%@,%@,%@,%@,%@",placeMark.country,_currentCity,placeMark.subLocality,placeMark.thoroughfare,placeMark.name];
|
||||
|
||||
NSUserDefaults*userdefult=[NSUserDefaults standardUserDefaults];
|
||||
NSString*address=message;
|
||||
self.adderss = address;
|
||||
[userdefult setObject:address forKey:@"address"];
|
||||
[userdefult setDouble:self.latitude forKey:@"userlatitude"];
|
||||
[userdefult setDouble:self.longitude forKey:@"userlongitude"];
|
||||
[userdefult synchronize];
|
||||
}else if (error == nil && placemarks.count){
|
||||
|
||||
NSLog(@"NO location and error return");
|
||||
}else if (error){
|
||||
|
||||
NSLog(@"loction error:%@",error);
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#pragma mark-- 获取验证(阿里)
|
||||
-(void)timeFire{
|
||||
|
||||
@@ -544,8 +626,8 @@ extern BOOL formLogIn;
|
||||
}
|
||||
#pragma mark 引导页
|
||||
-(void)viewWillAppear:(BOOL)animated{
|
||||
_geocodesearch.delegate=self;// 此处记得不用的时候需要置nil,否则影响内存的释放
|
||||
_locService.delegate=self;
|
||||
// _geocodesearch.delegate=self;// 此处记得不用的时候需要置nil,否则影响内存的释放
|
||||
// _locService.delegate=self;
|
||||
static dispatch_once_t disOnce;
|
||||
dispatch_once(&disOnce, ^ {
|
||||
if (_showed) {
|
||||
@@ -563,7 +645,7 @@ extern BOOL formLogIn;
|
||||
}
|
||||
-(void)viewWillDisappear:(BOOL)animated{
|
||||
// _geocodesearch.delegate=nil;
|
||||
_locService.delegate=nil;
|
||||
// _locService.delegate=nil;
|
||||
}
|
||||
-(void)showIntroduce{
|
||||
MyIntroductionViewController*introductionVC=[[MyIntroductionViewController alloc]init];
|
||||
@@ -658,60 +740,60 @@ extern BOOL formLogIn;
|
||||
|
||||
//实现相关delegate 处理位置信息更新
|
||||
//处理方向变更信息
|
||||
- (void)didUpdateUserHeading:(BMKUserLocation *)userLocation
|
||||
{
|
||||
//NSLog(@"heading is %@",userLocation.heading);
|
||||
}
|
||||
//- (void)didUpdateUserHeading:(BMKUserLocation *)userLocation
|
||||
//{
|
||||
// //NSLog(@"heading is %@",userLocation.heading);
|
||||
//}
|
||||
//处理位置坐标更新
|
||||
- (void)didUpdateBMKUserLocation:(BMKUserLocation *)userLocation
|
||||
{
|
||||
NSLog(@"didUpdateUserLocation lat %f,long %f",userLocation.location.coordinate.latitude,userLocation.location.coordinate.longitude);
|
||||
self.latitude = userLocation.location.coordinate.latitude;
|
||||
self.longitude = userLocation.location.coordinate.longitude;
|
||||
static dispatch_once_t disOnce;
|
||||
dispatch_once(&disOnce, ^ {
|
||||
|
||||
[self reverseGeoCodeWithlatitude:userLocation.location.coordinate.latitude addlongitude:userLocation.location.coordinate.longitude];
|
||||
});
|
||||
|
||||
}
|
||||
//- (void)didUpdateBMKUserLocation:(BMKUserLocation *)userLocation
|
||||
//{
|
||||
// NSLog(@"didUpdateUserLocation lat %f,long %f",userLocation.location.coordinate.latitude,userLocation.location.coordinate.longitude);
|
||||
// self.latitude = userLocation.location.coordinate.latitude;
|
||||
// self.longitude = userLocation.location.coordinate.longitude;
|
||||
// static dispatch_once_t disOnce;
|
||||
// dispatch_once(&disOnce, ^ {
|
||||
//
|
||||
// [self reverseGeoCodeWithlatitude:userLocation.location.coordinate.latitude addlongitude:userLocation.location.coordinate.longitude];
|
||||
// });
|
||||
//
|
||||
//}
|
||||
/**
|
||||
* 地理反编码
|
||||
*/
|
||||
-(void)reverseGeoCodeWithlatitude:(CLLocationDegrees)latitude addlongitude:(CLLocationDegrees)longitude{
|
||||
CLLocationCoordinate2D pt=(CLLocationCoordinate2D){latitude,longitude};
|
||||
BMKReverseGeoCodeOption *reverseGeocodeSearchOption = [[BMKReverseGeoCodeOption alloc]init];
|
||||
reverseGeocodeSearchOption.reverseGeoPoint=pt;
|
||||
BOOL flag = [_geocodesearch reverseGeoCode:reverseGeocodeSearchOption];
|
||||
if(flag)
|
||||
{
|
||||
NSLog(@"反geo检索发送成功");
|
||||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"反geo检索发送失败");
|
||||
}
|
||||
|
||||
}
|
||||
-(void)dealloc{
|
||||
|
||||
if (_geocodesearch!=nil) {
|
||||
_geocodesearch=nil;
|
||||
}
|
||||
}
|
||||
//-(void)reverseGeoCodeWithlatitude:(CLLocationDegrees)latitude addlongitude:(CLLocationDegrees)longitude{
|
||||
// CLLocationCoordinate2D pt=(CLLocationCoordinate2D){latitude,longitude};
|
||||
// BMKReverseGeoCodeOption *reverseGeocodeSearchOption = [[BMKReverseGeoCodeOption alloc]init];
|
||||
// reverseGeocodeSearchOption.reverseGeoPoint=pt;
|
||||
// BOOL flag = [_geocodesearch reverseGeoCode:reverseGeocodeSearchOption];
|
||||
// if(flag)
|
||||
// {
|
||||
// NSLog(@"反geo检索发送成功");
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// NSLog(@"反geo检索发送失败");
|
||||
// }
|
||||
//
|
||||
//}
|
||||
//-(void)dealloc{
|
||||
//
|
||||
// if (_geocodesearch!=nil) {
|
||||
// _geocodesearch=nil;
|
||||
// }
|
||||
//}
|
||||
|
||||
#pragma mark BMKGeoCodeSearchDelegate
|
||||
-(void)onGetReverseGeoCodeResult:(BMKGeoCodeSearch *)searcher result:(BMKReverseGeoCodeResult *)result errorCode:(BMKSearchErrorCode)error{
|
||||
NSLog(@"address%@",result.address);
|
||||
NSUserDefaults*userdefult=[NSUserDefaults standardUserDefaults];
|
||||
NSString*address=result.address;
|
||||
self.adderss = address;
|
||||
[userdefult setObject:address forKey:@"address"];
|
||||
[userdefult setDouble:self.latitude forKey:@"userlatitude"];
|
||||
[userdefult setDouble:self.longitude forKey:@"userlongitude"];
|
||||
[userdefult synchronize];
|
||||
_geocodesearch.delegate=nil;
|
||||
}
|
||||
//-(void)onGetReverseGeoCodeResult:(BMKGeoCodeSearch *)searcher result:(BMKReverseGeoCodeResult *)result errorCode:(BMKSearchErrorCode)error{
|
||||
// NSLog(@"address%@",result.address);
|
||||
// NSUserDefaults*userdefult=[NSUserDefaults standardUserDefaults];
|
||||
// NSString*address=result.address;
|
||||
// self.adderss = address;
|
||||
// [userdefult setObject:address forKey:@"address"];
|
||||
// [userdefult setDouble:self.latitude forKey:@"userlatitude"];
|
||||
// [userdefult setDouble:self.longitude forKey:@"userlongitude"];
|
||||
// [userdefult synchronize];
|
||||
// _geocodesearch.delegate=nil;
|
||||
//}
|
||||
|
||||
#pragma mark - countrySelectBtnAction
|
||||
|
||||
|
||||
Reference in New Issue
Block a user