0

If I have a list of annotation on the map, such as:

- (void)viewDidLoad
{
    [super viewDidLoad];

    self.mapView.delegate = self;
    self.mapView.mapType = MKMapTypeStandard;
    self.mapView.showsUserLocation = YES;

    MKPointAnnotation * myAnnotation1 = [[MKPointAnnotation alloc] init]; 
    myAnnotation1.coordinate = CLLocationCoordinate2DMake (41.7359004, 14.0307597); 
    myAnnotation1.title = @ "Via Fonticella"; 
    myAnnotation1.subtitle = @ "Alfedena"; 
    [self.mapView AddAnnotation: myAnnotation1]; 

    MKPointAnnotation * myAnnotation2 = [[MKPointAnnotation alloc] init]; 
    myAnnotation2.coordinate = CLLocationCoordinate2DMake (41.853382, 14.1997301); 
    myAnnotation2.title = @ "Way Station"; 
    myAnnotation2.subtitle = @ "Ateleta"; 
    [self.mapView AddAnnotation: myAnnotation2]; 

    MKPointAnnotation * myAnnotation3 = [[MKPointAnnotation alloc] init]; 
    myAnnotation3.coordinate = CLLocationCoordinate2DMake (42.0354183, 13.425821); 
    myAnnotation3.title = @ "Via Corradini 31"; 
    myAnnotation3.subtitle = @ "Avezzano"; 
    [self.mapView AddAnnotation: myAnnotation3];

    // up to 1000 etc..
}

How do I make a load only those close to the position?

The function for the position and the centering in the map is this:

- (IBAction)zoomToCurrentLocation
{
    float spanX = 0.00725;
    float spanY = 0.00725;

    MKCoordinateRegion region;

    region.center.latitude = self.mapView.userLocation.coordinate.latitude;
    region.center.longitude = self.mapView.userLocation.coordinate.longitude;

    region.span.latitudeDelta = spanX;
    region.span.longitudeDelta = spanY;

    [self.mapView setRegion:region animated:YES];
}
Marco Tini
  • 21
  • 5
  • You mean, add only few of which is near to the current location >? – Kumar KL Sep 17 '14 at 09:55
  • 1
    possible duplicate of [Draw a circle of 1000m radius around users location in MKMapView](http://stackoverflow.com/questions/9056451/draw-a-circle-of-1000m-radius-around-users-location-in-mkmapview) – Jai Govindani Sep 17 '14 at 10:13

1 Answers1

0

I think what you mean is showing annotations within certain radius.

Is this the answer that you're looking for?

Community
  • 1
  • 1
felixwcf
  • 2,078
  • 1
  • 28
  • 45