- (IBAction)showLocation:(id)sender {
//显示用户当前位置
dispatch_queue_t concurrentQueue = dispatch_queue_create("my.concurrent.queue", DISPATCH_QUEUE_CONCURRENT);
dispatch_sync(concurrentQueue, ^{
_mapView.showsUserLocation = YES;
[_mapView updateLocationData:_autoLocation];
[_mapView setCenterCoordinate:_autoLocation.location.coordinate animated:YES];
});
}
//处理方向变更信息
-(void)didUpdateUserHeading:(BMKUserLocation *)userLocation
{
NSLog(@"heading is %@", userLocation.heading);
[_mapView updateLocationData:userLocation];
}
//处理位置坐标变更
-(void)didUpdateBMKUserLocation:(BMKUserLocation *)userLocation
{
NSLog(@"update user location");
_autoLocation = userLocation;
_mapView.showsUserLocation = YES;//显示定位图层
[_mapView setCenterCoordinate:userLocation.location.coordinate animated:YES];
[_mapView updateLocationData:userLocation];
}
ps:
1、引用事件:BMKLocationServiceDelegate
2、实例
BMKLocationService*_locService;
_locService = [[BMKLocationService alloc]init];
[_locService startUserLocationService];
3、
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
// [_mapView viewWillAppear];
_mapView.delegate = self; // 此处记得不用的时候需要置nil,否则影响内存的释放
_locService.delegate = self;
}
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
[_mapView viewWillDisappear];
_mapView.delegate = nil; // 不用时,置nil
_locService.delegate = nil;
}