如果我在地图上有注释列表,例如:
- (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..
}
如何只为那些靠近位置的人加载?
地图中的位置和居中功能如下:
- (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];
}