使用GoogleAPI查找最近的地点 [英] Finding nearest places using GoogleAPI

查看:97
本文介绍了使用GoogleAPI查找最近的地点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个Iphone应用程序,使用GoogleAPI在500米范围内找到最近的卫生间。但我想做的事情是从距离当前位置较近的地方开始,以排序模式查找地点。



谢谢。

解决方案

假设 restroomLocations coordinatesArray userLocation 是用户当前的位置,并且您知道如何使用 CoreLocation 框架来获取所有用户的当前位置。下面的方法可以帮助你:

   - (NSMutableArray *)getRelevantRestrooms:(NSArray *)restroomLocations withUsersLocation:(CLLocation *)myLocation {
NSMutableArray * resultsArray = [[NSMutableArray alloc] init];
$ b $ for(CLLocation * location in restroomLocations){
if([location distanceFromLocation:myLocation]< = 500){
[resultsArray addObject:location];
}
}

return [resultsArray autorelease];
}


I am developing an Iphone application in which i am using GoogleAPI to find the nearest Restrooms within 500 meters. But the thing i want to do is to find the places in sorted pattern starting from places whose distance is less from current location.

Thanks.

解决方案

Assume restroomLocations is the coordinatesArray, userLocation is the user current location, and that you know how to use the CoreLocation framework to get all users' current location. The following method will help you:

-(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];
}

这篇关于使用GoogleAPI查找最近的地点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆