search

Home  >  Q&A  >  body text

ios - 百度地图定位didUpdateLocations为什么会触发两次?

-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations{
CLLocation *cation =[locations objectAtIndex:0];
NSLog(@"纬度--%f",cation.coordinate.latitude);
NSLog(@"经度--%f",cation.coordinate.longitude);
[self.locationManager stopUpdatingLocation];//停止更新位置
}

伊谢尔伦伊谢尔伦2773 days ago796

reply all(3)I'll reply

  • 大家讲道理

    大家讲道理2017-04-17 14:21:15

    This is not from Baidu, it is from Baidu- (void)didUpdateBMKUserLocation:(BMKUserLocation *)userLocation

    The bottom layer of Baidu will call those methods starting with CL. All of them are valuable. It is recommended to delete them and leave them to Baidu SDK for processing
    You just need to call - (void)didUpdateBMKUserLocation:(BMKUserLocation *)userLocation

    reply
    0
  • PHP中文网

    PHP中文网2017-04-17 14:21:15

    Why does it sometimes start twice and sometimes once?

    reply
    0
  • ringa_lee

    ringa_lee2017-04-17 14:21:15

    Original, this didUpdateLocations proxy method will be called multiple times, because when positioning, if the phone moves, the longitude and latitude will also change accordingly. This method is the corresponding changed longitude and latitude

    When I made Baidu Maps, the positioning requirements were not used -(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations

    The following
    - (void)mapViewWillStartLocatingUser:(BMKMapView *)mapView
    - (void)didUpdateUserHeading:(BMKUserLocation *)userLocation
    - (void)didUpdateBMKUserLocation:(BMKUserLocation *)userLocation
    - (void)mapViewDidStopLocatingUser:(BMKMapView *)mapView

    reply
    0
  • Cancelreply