iOS 高德地图 根据经纬度解析成位置

 //根据经纬度解析成位置

CGFloat latitude = [[MLUserModel sharedUserInfo].latitude floatValue];//经度

CGFloat longitude = [[MLUserModel sharedUserInfo].longitude floatValue];//纬度

 CLLocation *location = [[CLLocation alloc]initWithLatitude:latitude longitude:longitude];

  

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

 [geocoder reverseGeocodeLocation:location completionHandler:^(NSArray *placemark,NSError *error){

                CLPlacemark *mark = [placemark objectAtIndex:0];

               NSLog(@"%@%@%@%@%@",mark.subLocality,mark.thoroughfare,mark.name,mark.locality,mark.subLocality);

 }];

 

    //根据位置解析成经纬度

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

    [geocoder geocodeAddressString:@"地址" completionHandler:^(NSArray<CLPlacemark *> * _Nullable placemarks, NSError * _Nullable error) {

        CLPlacemark *mark = [placemarks objectAtIndex:0];

        weakself.centerCoordinate = mark.location.coordinate;

    }];

posted on 2017-11-09 14:09  廖利君  阅读(692)  评论(0编辑  收藏  举报