- (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<MKAnnotation>)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;
}