Iphone 使用GoogleAPI查找最近的位置

Iphone 使用GoogleAPI查找最近的位置,iphone,objective-c,google-maps,google-maps-api-3,Iphone,Objective C,Google Maps,Google Maps Api 3,我正在开发一个Iphone应用程序,其中我使用GoogleAPI查找500米范围内最近的洗手间。但我想做的是从距离当前位置较短的位置开始,找到排序模式中的位置 谢谢。假设restroomLocations是协调阵列,userLocation是用户当前位置,并且您知道如何使用CoreLocation框架获取所有用户的当前位置。以下方法将帮助您: -(NSMutableArray *)getRelevantRestrooms:(NSArray *)restroomLocations withUser

我正在开发一个Iphone应用程序,其中我使用GoogleAPI查找500米范围内最近的洗手间。但我想做的是从距离当前位置较短的位置开始,找到排序模式中的位置


谢谢。

假设
restroomLocations
协调阵列
userLocation
是用户当前位置,并且您知道如何使用
CoreLocation
框架获取所有用户的当前位置。以下方法将帮助您:

-(NSMutableArray *)getRelevantRestrooms:(NSArray *)restroomLocations withUsersLocation:(CLLocation *)myLocation{
    NSMutableArray *resultsArray=[[NSMutableArray alloc]init];

    for (CLLocation *location in restroomLocations) {
        if ([location distanceFromLocation:myLocation]<=500){
            [resultsArray addObject:location];
        }
    }

    return [resultsArray autorelease];
}
-(NSMutableArray*)获取相关洗手间:(NSArray*)洗手间位置和用户位置:(CLLocation*)我的位置{
NSMutableArray*resultsArray=[[NSMutableArray alloc]init];
用于(CLLocation*洗手间位置){

如果([location distanceFromLocation:myLocation]假设
restroomLocations
协调阵列
用户位置
是用户当前位置,并且您知道如何使用
CoreLocation
框架获取所有用户的当前位置。以下方法将帮助您:

-(NSMutableArray *)getRelevantRestrooms:(NSArray *)restroomLocations withUsersLocation:(CLLocation *)myLocation{
    NSMutableArray *resultsArray=[[NSMutableArray alloc]init];

    for (CLLocation *location in restroomLocations) {
        if ([location distanceFromLocation:myLocation]<=500){
            [resultsArray addObject:location];
        }
    }

    return [resultsArray autorelease];
}
-(NSMutableArray*)获取相关洗手间:(NSArray*)洗手间位置和用户位置:(CLLocation*)我的位置{
NSMutableArray*resultsArray=[[NSMutableArray alloc]init];
用于(CLLocation*洗手间位置){

if([location distanceFromLocation:myLocation]感谢您的回复,但我需要知道如何根据距离我所在位置最近的距离来确定我检索的位置。您可以使用R-Tree查找范围内的位置和/或k-d树查找m-最近的位置,例如。这些数据结构通常隐藏在服务器上的API调用后面。感谢您的回复但我需要知道,如何根据距离我的位置最近的距离来确定检索的位置。您可以使用R-Tree查找范围内的位置和/或k-d树查找m-最近的位置,例如。这些数据结构通常隐藏在服务器上的API调用后面。