Search Results

Search found 3 results on 1 pages for 'teddafan'.

Page 1/1 | 1 

  • MapKit Annotations and User location

    - by teddafan
    Hi all, I followed this tutorial to make my first app: http://icodeblog.com/2009/12/21/introduction-to-mapkit-in-iphone-os-3-0/ I would really like to know how to sort the annotations in the Table in order of distance to the user (the nearest annotation is the first one on the table) How is it possible to do that? I understand that I must use the CLLocation to find the user's location but then I have no idea. Could any one help me? Cheers, Thank you in advance for your much appreciated help, teddafan

    Read the article

  • Limit to 10 number of annotations in mapkit!

    - by teddafan
    Hi, I have all my annotations(as nsdictionnaries) in an array , and the users add them one by one by tapping on an icon. I want to make it impossible after adding 10 annotations (there is 110). Is it here i have to make something?: -(IBAction) plusButtonTapped: (id) sender { NSDictionary *poiDict = [poiArray objectAtIndex:nextPoiIndex++]; CLLocationCoordinate2D poiCoordinate; poiCoordinate.latitude = [[poiDict valueForKey:@"workingCoordinate.latitude"] doubleValue]; poiCoordinate.longitude = [[poiDict valueForKey:@"workingCoordinate.longitude"] doubleValue]; MyMapAnnotation *poiAnnotation = [[MyMapAnnotation alloc] initWithCoordinate:poiCoordinate title:[poiDict valueForKey:@"Subtitle"] color:MKPinAnnotationColorRed ]; [mapView addAnnotation:poiAnnotation]; [self adjustMapZoom]; } Thank you for your help in advance, teddafan

    Read the article

  • Limit Annotation number in Mapkit

    - by teddafan
    Hi all, I want to stop my app from loading more annotations after they are all added ( they are added by the user one by one). How would you do that? the following code is what i think is important (void) loadAndSortPOIs { [poiArray release]; nextPoiIndex = 0; NSString *poiPath = [[NSBundle mainBundle] pathForResource:@"pois" ofType:@"plist"]; poiArray = [[NSMutableArray alloc] initWithContentsOfFile:poiPath]; CLLocation *homeLocation = [[CLLocation alloc] initWithLatitude:homeCoordinate.latitude longitude:homeCoordinate.longitude]; for (int i = 0; i < [poiArray count]; i++) { NSDictionary *dict = (NSDictionary*) [poiArray objectAtIndex: i]; CLLocationDegrees storeLatitude = [[dict objectForKey:@"workingCoordinate.latitude"] doubleValue]; CLLocationDegrees storeLongitude = [[dict objectForKey:@"workingCoordinate.longitude"] doubleValue]; CLLocation *storeLocation = [[CLLocation alloc] initWithLatitude:storeLatitude longitude:storeLongitude]; CLLocationDistance distanceFromHome = [storeLocation getDistanceFrom: homeLocation]; NSMutableDictionary *mutableDict = [[NSMutableDictionary alloc] initWithDictionary:dict]; [mutableDict setValue:[NSNumber numberWithDouble:distanceFromHome] forKey:@"distanceFromHome"]; [poiArray replaceObjectAtIndex:i withObject:mutableDict]; [mutableDict release]; } [homeLocation release]; // now sort by distanceFromHome NSArray *sortDescriptors = [NSArray arrayWithObject: [[NSSortDescriptor alloc] initWithKey: @"distanceFromHome" ascending: YES]]; [poiArray sortUsingDescriptors:sortDescriptors]; NSLog (@"poiArray: %@", poiArray); } Thank you for your help. Best regards,

    Read the article

1