可以在MKmapview上添加多个引脚吗?。我添加了一个并完成了注释,我希望在MKMapview.Pls上添加多个引脚帮助我。
答案 0 :(得分:7)
只需使用[mapView addAnnotations:]而不是addAnnotation。 你必须为它提供一个注释数组。
答案 1 :(得分:1)
答案 2 :(得分:0)
/// ExplainClass是新类,其中声明了cordinate,tittle,subtitle
ExplainClass
@property (nonatomic, assign) CLLocationCoordinate2D coordinate;
@property (nonatomic, copy) NSString *title;
@property (nonatomic, copy) NSString *subtitle;
// Map Class
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];