简体   繁体   English

MKMapview 上的多个引脚

[英]Multiple pins on MKMapview

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.是否可以在 MKmapview 上添加多个引脚?我已经添加了一个并完成了注释,我希望在 MKMapview 上添加多个引脚。请帮帮我。

Just simply use the [mapView addAnnotations:] instead of addAnnotation.只需简单地使用 [mapView addAnnotations:] 代替 addAnnotation。 You'll have to provide an Array of your annotations for it.您必须为其提供一个注释数组。

This link MapKit Code Source might provide some useful information to you.此链接MapKit代码源可能会为您提供一些有用的信息。

Enjoy coding:)享受编码:)

Find the source code at the bottom of the tut..在教程底部找到源代码..

/// ExplainClass is new class in which have declare cordinate,tittle,sutitle /// ExplainClass 是新的 class,其中声明了坐标、标题、标题

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM