Reputation: 91
Is it possible to add multiple pins on MKmapview?.I have added one and done the annotation,Am looking to add multiple pins on MKMapview.Pls help me out.
Upvotes: 2
Views: 4201
Reputation: 359
/// ExplainClass is new class in which have declare cordinate,tittle,sutitle
ExplainClass
@property (nonatomic, assign) CLLocationCoordinate2D coordinate;
@property (nonatomic, copy) NSString *title;
@property (nonatomic, copy) NSString *subtitle;
// MapClass
MKMapView *mapView;
MKCoordinateRegion region = { {0.0, 0.0}, {0.0, 0.0} };
region.center.latitude = 22.569722 ;
region.center.longitude = 88.369722;
region.span.longitudeDelta = 0.01f;
region.span.latitudeDelta = 0.01f;
[mapView setRegion:region animated:YES];
MKCoordinateRegion region1 = { {0.0, 0.0}, {0.0, 0.0} };
region1.center.latitude = 37.786996 ;
region1.center.longitude = -122.419281;
region1.span.longitudeDelta = 0.01f;
region1.span.latitudeDelta = 0.01f;
[mapView setRegion:region1 animated:YES];
[mapView setDelegate:self];
ExplainClass *ann = [[ExplainClass alloc] init];
ann.title = @" Kolkata";
ann.subtitle = @"Mahatma Gandhi Road";
ann.coordinate = region.center;
ExplainClass *ann1 = [[ExplainClass alloc] init];
ann.title = @" Abc";
ann.subtitle = @"Road";
ann.coordinate = region1.center;
[mapView addAnnotation:ann];
[mapView addAnnotation:ann1];
Upvotes: 0
Reputation: 5766
Just simply use the [mapView addAnnotations:] instead of addAnnotation. You'll have to provide an Array of your annotations for it.
Upvotes: 7