高德地图 定位和位置信息获取

- (void)viewDidLoad

{

    

    [super viewDidLoad];

      self.navigationController.navigationBarHidden = YES;

  

    _mapView = [[MAMapView alloc] init];

    _mapView.frame  =CGRectZero;

    [self.view addSubview:_mapView];

    _mapView.showsUserLocation = YES;

    

}

-(void)mapView:(MAMapView *)mapView didUpdateUserLocation:(MAUserLocation *)userLocation

updatingLocation:(BOOL)updatingLocation

{

    NSLog(@"didUpdateUserLocationdidUpdateUserLocationdidUpdateUserLocation");

    CLLocation *currentLocation = userLocation.location;

    if(updatingLocation)

    {

        //取出当前位置的坐标

        NSLog(@"latitude : %f,longitude: %f ",userLocation.coordinate.latitude,userLocation.coordinate.longitude);

        //        [userLocation.]

    }

    CLGeocoder *geocoder = [[CLGeocoder alloc] init];

    [geocoder reverseGeocodeLocation:currentLocation completionHandler:^(NSArray *placemarks, NSError *error) {

        for (CLPlacemark *place in placemarks) {

            //                           UILabel *label = (UILabel *)[self.window viewWithTag:101];

            //                           label.text = place.name;

                                     NSLog(@"name,%@",place.name);                       // 位置名

                                                                  NSLog(@"thoroughfare,%@",place.thoroughfare);       // 街道

                                                                 NSLog(@"subThoroughfare,%@",place.subThoroughfare); // 子街道

            //                           //                           NSLog(@"locality,%@",place.locality);               // 市

            //                           //                           NSLog(@"subLocality,%@",place.subLocality);         // 区

            //                           //                           NSLog(@"country,%@",place.country);                 // 国家

                                   }

 

    }];

 

}

 

posted on 2015-07-07 11:12  流以琳elim  阅读(650)  评论(0编辑  收藏  举报

导航