//定位方法
-(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
}