我正在使用 for 循环获取从当前位置到目标位置的距离。我想要一个包含从当前位置到目标位置的所有距离的数组。
for (i = 0; i < [Arr_Lat count]; i++)
{
NSString *latst1 = [[NSString alloc]initWithFormat:[Arr_Lat objectAtIndex:i]];
NSString *longst1 = [[NSString alloc]initWithFormat:[Arr_Long objectAtIndex:i]];
NSLog(@"First lat : %@",latst1);
NSLog(@"First ong : %@",longst1);
double Doblat1 = [latst1 doubleValue];
double Doblong1 = [longst1 doubleValue];
CLLocationCoordinate2D coord1 = CLLocationCoordinate2DMake(coord1.latitude = Doblat1, coord1.longitude = Doblat1);
NSLog(@" Coordinat ==== : %f -- %f",coord1.latitude,coord1.longitude) ;
CLLocation *currLoc = [[CLLocation alloc] initWithLatitude:appDel.curr_lat longitude:appDel.curr_long];
CLLocation *destLoc1 = [[CLLocation alloc] initWithLatitude:Doblat1 longitude:Doblong1];
NSLog(@" Currennt Location : %@", currLoc);
NSLog(@" Destination Location : %@" , destLoc1);
distance = [destLoc1 distanceFromLocation:currLoc];
NSLog(@" Distance : ------- %0.3f", distance);
DistStr = [[NSString alloc]initWithFormat:@" %f",distance];
[currLoc release];
[destLoc1 release];
[Arr_title retain];
[tbl_nearplace reloadData];
}