IOS 百度地图定位使用(不显示用户当前坐标)

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

 - (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;

}




转载于:https://my.oschina.net/jack088/blog/545978

你可能感兴趣的:(移动开发,python)