IOS 定位当前位置

//定位方法
-(void)GPSLocation
{
    if(!_gpsSertice){
        _gpsSertice = [[LocationServicealloc]init];
        __weak typeof(self) selfBlock =self;
        __weak typeof(UITableView*) tableViewBlock =_tableView;
         __weak Phy_PackagesDetailController *ws=self;
        _gpsSertice.startLocation = ^(){
            CLog(@"正在定位,请稍候...");
        };
        _gpsSertice.successResult = ^(AMapReGeocode *info,CLLocationCoordinate2D coordinate,NSString *msg){
            CLog(@"定位结束");
            if(!msg){
                
                _lat = [NSStringstringWithFormat:@"%f",coordinate.latitude];
                _lon = [NSStringstringWithFormat:@"%f",coordinate.longitude];
                [ws hosListByProduct];//定位成功之后执行根据套餐查适合的机构
                [tableViewBlock.mj_header beginRefreshing];
            }else{
                [selfBlock.alertView showMessage:msg];
            }
        };
    }
    [_gpsSertice start];
}





-(void)start
{
    //模拟器坐标设置
    #ifdef TARGET_OS_SIMULATOR
    _coordinate.longitude =113.331056;
    _coordinate.latitude =23.138974;
    [selfmapView:nildidUpdateUserLocation:nilupdatingLocation:NO];
    #else
    if([CLLocationManager locationServicesEnabled]){
        CLAuthorizationStatus status = [CLLocationManager authorizationStatus];
        if(status == kCLAuthorizationStatusDenied ||
           status == kCLAuthorizationStatusNotDetermined ||
           status == kCLAuthorizationStatusRestricted)
        {
            _successResult(nil,_coordinate,kMessageTIPS_GPS);
        }else{
            if(!_mapView.showsUserLocation){
                [self stop];
            }
            _mapView.showsUserLocation = YES;
        }
    }else{
        _successResult(nil,_coordinate,kMessageTIPS_GPS);
    }
    #endif
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

码农老K

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值