gpt4 book ai didi

ios - 如何使用 Parse 找到当前用户位置附近的用户?

转载 作者:塔克拉玛干 更新时间:2023-11-02 10:05:39 26 4
gpt4 key购买 nike

我的应用需要找到用户的当前位置,我已经完成了。然后它需要找到在当前用户位置附近的其他用户。我正在为此使用 Parse。到目前为止,这是我必须获取用户当前位置的方法,并且到目前为止它正在工作。不过我不明白如何在当前用户位置附近找到其他用户。有人可以帮帮我吗?我真的很感激。

if ([PFUser currentUser] && [PFFacebookUtils isLinkedWithUser:[PFUser currentUser]]) {
[self updateUserInformation];

[PFGeoPoint geoPointForCurrentLocationInBackground:^(PFGeoPoint *geoPoint, NSError *error) {
if (!error) {
NSLog(@"User is currently at %f, %f", geoPoint.latitude, geoPoint.longitude);
[[PFUser currentUser] setObject:geoPoint forKey:@"currentLocation"];
[[PFUser currentUser] saveInBackground];
} else {
NSLog(@"%@", error);
return;
}
}];

最佳答案

来自解析文档:

// User's location
PFGeoPoint *userGeoPoint = userObject[@"currentLocation"];
// Create a query for places
PFQuery *query = [PFQuery queryWithClassName:@"_User"];
// Interested in locations near user.
[query whereKey:@"location" nearGeoPoint:userGeoPoint];
// Limit what could be a lot of points.
query.limit = 10;
// Final list of objects
placesObjects = [query findObjects];

placesObjects 将是一组对象,按距 userGeoPoint 的距离(从最近到最远)排序。

https://www.parse.com/docs/ios_guide#geo-query/iOS

关于ios - 如何使用 Parse 找到当前用户位置附近的用户?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23093557/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com