Today I have write about to getting particular area.
First getting the list of location save into array and passed this array to below function
Cheers!!!
First getting the list of location save into array and passed this array to below function
| 01 | -(NSArray*)findNearMe:(NSArray*)lounges { | 
| 02 | NSMutableArray*arNearme = [NSMutableArrayarray]; | 
| 03 | 
| 04 | CLLocation *currentLocation; | 
| 05 | 
| 06 | for(NSDictionary*d in lounges) | 
| 07 | { | 
| 08 | if([[LocationController sharedInstance] locationKnown] == YES) | 
| 09 | { | 
| 10 | currentLocation = [[LocationController sharedInstance] currentLocation]; | 
| 11 | } | 
| 12 | else | 
| 13 | { | 
| 14 | currentLocation = [[CLLocation alloc] initWithLatitude:29.33891 longitude:48.077202]; | 
| 15 | } | 
| 16 | //        NSLog(@"Current Location : %@",[currentLocation description]); | 
| 17 | 
| 18 | CGFloat latitude=[[d valueForKey:@"latitude"] floatValue]; | 
| 19 | CGFloat longitude=[[d valueForKey:@"longitude"] floatValue]; | 
| 20 | CLLocation *newPinLocation=[[CLLocation alloc] initWithLatitude:latitude longitude:longitude]; | 
| 21 | doubledistanceValue=[currentLocation distanceFromLocation:newPinLocation]; | 
| 22 | 
| 23 | if(distanceValue/1000.0<=DISTANCE_RADIUS) { | 
| 24 | //            NSLog(@"Distance value : %f",distanceValue); | 
| 25 | [arNearme addObject:d]; | 
| 26 | } | 
| 27 | } | 
| 28 | //    NSLog(@"Near Me Lounges : %d\n%@",[arNearme count], [arNearme description]); | 
| 29 | 
| 30 | returnarNearme; | 
| 31 | } | 
Cheers!!!
how to convert distance in kilometer from miles in iPhone
distance = [currentLocation1 distanceFromLocation:currentLocation2]/1609.344;
How to convert distance from current position in iPhone
| 01 | -(void)convertToDistance | 
| 02 | { | 
| 03 | 
| 04 |     CLLocation* currentLocation1 = [[[CLLocation alloc] initWithLatitude:142.56567 longitude:72.6567 autorelease]; | 
| 05 |     CLLocation* currentLocation2 = [[[CLLocation alloc] initWithLatitude:145.8797 longitude:71.8778 autorelease]; | 
| 06 |             floatdistance = 0; | 
| 07 |             floatsystemVersion = [[[UIDevice currentDevice] systemVersion] floatValue]; | 
| 08 |             if(systemVersion >= 4.0){ | 
| 09 |                 distance =  [currentLocation1 distanceFromLocation:currentLocation2] | 
| 10 |             } | 
| 11 |             elseif(systemVersion <= 3.0){ | 
| 12 |                 distance =  [currentLocation1 getDistanceFrom:currentLocation2] | 
| 13 |             } | 
| 14 |             NSString*temp = [NSStringstringWithFormat:@"%0.1fkm", distance]; | 
| 15 |     } | 
Every coders have error. if you have any doubt or found any mistake in my post, use the comment feature below share with me!
Cheers every Coder!!!
 
No comments:
Post a Comment