地图拼图中的多个注释

问题描述:

enter image description here我有点作为地图上的pin注释并显示自定义注释视图。我的问题是,当我点击点时,点后面的自定义注释视图来自定义注释视图而不是显示在后面它。地图拼图中的多个注释

-(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation 
{ 
    MKAnnotationView *annotationView; 
    PinAnnotationView *pinView = nil; 
    NSString *identifier; 
    if ([annotation isKindOfClass:[DisplayMap class]]) 
    { 
     identifier = @"Pin"; 
     NSInteger myid = ((DisplayMap *)annotation).takeid; 
     MKAnnotationView *pinView = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier]; 
     DisplayMap *a = (DisplayMap *)annotation; 
     pinView.annotation=a; 
     if (myid == 1) 
     { 
      UIImage *test = [UIImage imageNamed:@"red_dot.png"]; 
      pinView.image = test; 
      pinView.opaque = NO; 
     } 
     else if (myid == 2) 
     { 
      UIImage *test = [UIImage imageNamed:@"blue_dot.png"]; 
      pinView.image = test; 
      pinView.opaque = NO; 
     } 
     else { 
      UIImage *test = [UIImage imageNamed:@"green_dot.png"]; 
      pinView.image = test; 
      pinView.opaque = NO; 
     } 
    return pinView; 
    } 
    else if ([annotation isKindOfClass:[CalloutAnnotation class]]) 
    { 
     identifier = [NSString stringWithFormat:@"Callout%d",pinView.tag]; 
     annotationView = [[CalloutAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier]; 
     CalloutAnnotation *calloutAnnotation = (CalloutAnnotation *)annotation; 
     ((CalloutAnnotationView *)annotationView).title = calloutAnnotation.title; 
     ((CalloutAnnotationView *)annotationView).iTag = calloutAnnotation.iTag; 
     [annotationView setNeedsDisplay]; 
     [UIView animateWithDuration:0.5f 
        animations:^(void) { 
         mapView.centerCoordinate = calloutAnnotation.coordinate; 
        }]; 
     annotationView.annotation = annotation; 
     return annotationView; 
    } 
} 


-(void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view1 
{ 
    if ([view1.annotation isKindOfClass:[DisplayMap class]]) 
    { 
    DisplayMap *pinAnnotation = ((DisplayMap *)view1.annotation); 
    LoginDetail *obj = [[appDelegate mapArray] objectAtIndex:pinAnnotation.iTag]; 
    [mapView removeAnnotations:annotationRemoveArray]; 

    CalloutAnnotation *calloutAnnotation = [[CalloutAnnotation alloc] init]; 
    calloutAnnotation.title  = pinAnnotation.title; 
    pinAnnotation.calloutAnnotation = calloutAnnotation; 
    [mapView addAnnotation:calloutAnnotation]; 
    [annotationRemoveArray addObject:calloutAnnotation]; 
    [self setzoomonselectannotation:pinAnnotation.coordinate]; 
    } 
} 
+2

请提高的问题 –

+1

发布一些代码:( – Rushabh

+0

尝试删除所有其他注释和只显示当前 –

标注窗口也是一个注释视图。这是错误的;)

遵循一个提示: How to customize the callout bubble for MKAnnotationView?

基本上他们在说什么:做标注针本身的一个子视图