在地图上删除多个引脚,Xcode

时间:2014-05-14 17:52:01

标签: ios mkmapview

所以我有这个代码在我的iPhone应用程序中删除谷歌地图中的一个Pin。

你知道我怎么能放下多个Pins来展示业务的不同位置吗?

#import "NewClass.h"
@implementation ViewController
  -(void)viewDidLoad {
    [super viewDidLoad];

      MKCoordinateRegion region = { {0.0, 0.0}, {0.0,0.0}};
      region.center.latitude = 40.707184;
      region.center.longitude = -73.998392;
      region.span.longitudeDelta = 0.01f;
      region.span.latitudeDelta = 0.01f;
      [mapview setRegion:region animated:YES];

      MapPin *ann = [[MapPin alloc] init];
      ann.title = @"Brooklyn Bridge";
      ann.subtitle = @"New York";
      ann.coordinate = region.center;
     [mapview addAnnotation:ann];

  }

我的重复尝试

MKCoordinateRegion region = { {0.0, 0.0}, {0.0,0.0}};
region.center.latitude = 53.0838491;
region.center.longitude = -2.7998707;
region.span.longitudeDelta = 0.01f;
region.span.latitudeDelta = 0.01f;
[mapview setRegion:region animated:YES];

NewClass *ann = [[NewClass alloc] init];
ann.title = @"Making Waves Swim School";
ann.subtitle = @"Clutton, Cheshire";
ann.coordinate = region.center;
[mapview addAnnotation:ann];

MKCoordinateRegion region2 = { {0.0, 0.0}, {0.0,0.0}};
region2.center.latitude = 53.199801;
region2.center.longitude = -2.89744;
region2.span.longitudeDelta = 0.01f;
region2.span.latitudeDelta = 0.01f;
[mapview setRegion:region2 animated:YES];

NewClass *ann2 = [[NewClass alloc] init];
ann2.title = @"Chester Uni";
ann2.subtitle = @"Chester, Cheshire";
ann2.coordinate = region.center;
[mapview addAnnotation:ann2];

1 个答案:

答案 0 :(得分:3)

ann2.coordinate = region.center;

应该是

ann2.coordinate = region2.center;

因此2个引脚的坐标不完全相同。