如何从Facebook用户位置获取纬度和经度?

时间:2014-02-12 01:27:36

标签: ios objective-c facebook-graph-api facebook-fql facebook-login

我设法恢复了下面代码中指定的所有信息,但我无法检索user.location的纬度和经度。

- (void)loginViewFetchedUserInfo:(FBLoginView *)loginView user:(id<FBGraphUser>)user {
        NSString *fbUsername = [NSString stringWithFormat:@"%@",user.username];
        NSString *fbNickname = [NSString stringWithFormat:@"%@",user.name];
        NSString *fbName = [NSString stringWithFormat:@"%@",user.first_name];
        NSString *fbSurname = [NSString stringWithFormat:@"%@",user.last_name];
        NSString *fbLocation = [NSString stringWithFormat:@"%@",user.location.name];
}

请帮助我!

2 个答案:

答案 0 :(得分:1)

要获取用户的经度和经度,请在您发布的方法中尝试:

NSNumber *userLatitude = user.location.location.latitude;
NSNumber *userLatitude = user.location.location.latitude;
//do whatever you want with the values here

答案 1 :(得分:0)

     - (void)placePickerViewControllerSelectionDidChange:(FBPlacePickerViewController *)placePicker
 {
// id&#060;
 // FBGraphPlace&#062;
 place = placePicker.selection;


 // we'll use logging to show the simple typed property access to place and location info
 NSLog(@"place=%@, city=%@, state=%@, lat long=%@ %@",
 place.name,
 place.location.city,
 place.location.state,
 place.location.latitude,
 place.location.longitude);
 }