我怎样才能获得距离我当前位置30米半径范围内的所有位置

时间:2012-10-10 04:35:42

标签: iphone ios map reverse-geocoding

对于我的项目,我想找到/放置附近位置的引脚。

1 个答案:

答案 0 :(得分:1)

试试这个,

CLLocationDistance radius = 30;
CLLocation* target = [[CLLocation alloc] initWithLatitude:someLat longitude:someLon];


NSArray *locationsWithinRadius = [locations objectsAtIndexes:
                                 [locations indexesOfObjectsPassingTest:
                                  ^BOOL(id obj, NSUInteger idx, BOOL *stop) {

                                      return [(CLLocation*)obj distanceFromLocation:target] < radius;

                                  }]];

[target release];