iOS 地图 自定义以及添加锚点

//联系人:石虎QQ: 1224614774昵称:嗡嘛呢叭咪哄

//自定义添加锚点

- (void)clickLongPress:(UILongPressGestureRecognizer *)longPress {

CGPoint point = [longPress locationInView:mapView];

CLLocationCoordinate2D coord = [mapView convertPoint:point toCoordinateFromView:mapView];

CLLocation *location = [[CLLocation alloc] initWithLatitude:coord.latitude longitude:coord.longitude];

MKPointAnnotation *annocation = [[MKPointAnnotation alloc] init];

annocation.coordinate = coord;

annocation.title = @"我的锚点";

[mapView addAnnotation:annocation];

}

//代理方法   签协议 MKMapViewDelegate

-(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id)annotation{

static NSString *annoid = @"str";

MKAnnotationView *annoView = [mapView dequeueReusableAnnotationViewWithIdentifier:annoid];

if (!annoView) {

annoView = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:annoid];

}

annoView.image = [UIImage imageNamed:@"1"];

return annoView;

}

谢谢!!!

你可能感兴趣的:(iOS 地图 自定义以及添加锚点)