iPhone SDK:附近位置功能

iPhone SDK:附近位置功能,iphone,mkmapview,Iphone,Mkmapview,我有一个iphone应用程序,它使用MKMapView在谷歌地图上显示企业列表及其位置。作为一个新功能,我正在尝试添加一个“附近”功能,它可以获取用户的当前位置,并在谷歌地图(比如10公里)附近显示几个地图注释。目前,企业位置作为地址字符串存储在mysql数据库中,然后检索并进行地理编码,将其显示在谷歌地图上 我该怎么做呢?如果附近有教程,请给我指一个。(我没有找到一个)。 提前谢谢 更新: 我让它部分工作-它只显示20公里半径范围内的企业,这很好,我遇到的问题是,当他们打开附近的企业视图时,它

我有一个iphone应用程序,它使用MKMapView在谷歌地图上显示企业列表及其位置。作为一个新功能,我正在尝试添加一个“附近”功能,它可以获取用户的当前位置,并在谷歌地图(比如10公里)附近显示几个地图注释。目前,企业位置作为地址字符串存储在mysql数据库中,然后检索并进行地理编码,将其显示在谷歌地图上

我该怎么做呢?如果附近有教程,请给我指一个。(我没有找到一个)。 提前谢谢

更新:

我让它部分工作-它只显示20公里半径范围内的企业,这很好,我遇到的问题是,当他们打开附近的企业视图时,它需要花费相当长的时间来检查每个企业,并检查用户和每个企业之间的距离。有没有办法加快速度?这是我的代码:,这两个方法都是从viewDidLoad方法调用的

-(void)getMapData
{
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init];

    NSInteger *bizMax = [[numOfBiz objectAtIndex:0]intValue];

    int x = 0;
    while(x < bizMax)
    {

        NSURL *mapURL = [NSURL URLWithString:[NSString stringWithFormat:@"getBizMap-xml.php?biz_id=%@",[bizIDS objectAtIndex:x]]];
        NSMutableArray *mapArray = [[NSMutableArray alloc] initWithContentsOfURL:mapURL];
        self.mapLocation = mapArray;
        self.mapStringLocation = [mapArray objectAtIndex:0];
        NSLog(@"Location: %@",mapStringLocation);
        [mapArray release];

        CLLocationCoordinate2D trueLocation = [self getLocationFromAddressString:mapStringLocation];
        AddressAnnotation *addAnnotation = [[AddressAnnotation alloc] initWithCoordinate:trueLocation];

        CLLocation *bizLoc = [[CLLocation alloc] initWithLatitude:trueLocation.latitude longitude:trueLocation.longitude];

        CLLocation *userLocation = [[CLLocation alloc] initWithLatitude:nearbyMapView.userLocation.coordinate.latitude longitude:nearbyMapView.userLocation.coordinate.longitude];
        //double distance = [userLocation getDistanceFrom: bizLoc] / 1000;

        double kilometers = [userLocation distanceFromLocation:bizLoc] / 1000;

        NSLog(@"Distance from %@ to current location is %g",mapStringLocation,kilometers);

        if(kilometers < maxDistance)
        {    
            [self.nearbyMapView addAnnotation:addAnnotation];
            [addAnnotation release];   
        }

        x++;
    }

    [pool release];        
}

-(void)getNumOfBusinesses
{    
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init];

    NSString *numOfBizJSON = [[NSString alloc]initWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat:@"numOfBiz.php"]]];

    NSString *bizIDSJSON = [[NSString alloc]initWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat:@"allBizIDSJSON.php"]]];

    SBJsonParser *parser = [[SBJsonParser alloc]init];
    numOfBiz = [[parser objectWithString:numOfBizJSON error:nil]copy];
    bizIDS = [[parser objectWithString:bizIDSJSON error:nil]copy];
    NSLog(@"biz id 1 = %@",[bizIDS objectAtIndex:0]);
    [parser release];
    [numOfBizJSON release];
    [bizIDSJSON release];

    [pool release];   
}
-(void)getMapData
{
NSAutoreleasePool*池=[[NSAutoreleasePool alloc]init];
NSInteger*bizMax=[[numobiz objectAtIndex:0]intValue];
int x=0;
while(x
这并不难。您可以获取所有数据,计算您与位置之间的距离。下一步是将距离与maxDistance(搜索半径)进行比较。如果距离 我认为这可以用很少的可可知识来实现


如果你需要更具体的东西,开始编码,我会帮你的

这并不难。您可以获取所有数据,计算您与位置之间的距离。下一步是将距离与maxDistance(搜索半径)进行比较。如果距离 我认为这可以用很少的可可知识来实现


如果你需要更具体的东西,开始编码,我会帮你的

源数据是否有可能嵌入GPS位置及其地址?或者更好的是,你打电话来提供一个总结,其中包括所有的业务在一个点击。如果你有太多的数据无法合理地放入一个响应中,那么你也有太多的数据无法单独循环。源数据是否有可能嵌入GPS位置及其地址?或者更好的是,你打电话来提供一个总结,其中包括所有的业务在一个点击。如果你有太多的东西无法合理地融入到一个响应中,那么你也有太多东西无法单独循环。