MKMapview上的多个引脚

时间:2011-07-22 18:44:33

标签: iphone ios mkmapview

可以在MKmapview上添加多个引脚吗?。我添加了一个并完成了注释,我希望在MKMapview.Pls上添加多个引脚帮助我。

3 个答案:

答案 0 :(得分:7)

只需使用[mapView addAnnotations:]而不是addAnnotation。 你必须为它提供一个注释数组。

答案 1 :(得分:1)

此链接MapKit代码来源可能会为您提供一些有用的信息。

享受编码:)

找到tut底部的源代码..

答案 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];