2014-12-09 7 views
0

Kingpin지도 핀 클러스터링 라이브러리 (현재 here에 있음)를 사용하는지도 응용 프로그램을 구축했습니다. 현재 라이브러리는 핀 위치를 근사하고 클러스터 핀을 배치하는 데 성공합니다. 그러나 원래 핀은 here처럼 제거되지 않습니다.Kingpin 주석이있는 사용자 정의 주석이있는 Apple MapKit

-(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation{ 
MKAnnotationView *annotationView = nil; 
if([annotation isKindOfClass:[KPAnnotation class]]){ 
    KPAnnotation *kingpinAnnotation = (KPAnnotation *)annotation; 
    if ([kingpinAnnotation isCluster]) { 
     annotationView=(MKAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:@"cluster"]; 
     if (annotationView==nil){ 
      annotationView=[[MKAnnotationView alloc]initWithAnnotation:kingpinAnnotation reuseIdentifier:@"cluster"]; 
      annotationView.canShowCallout=YES; 

      annotationView.image=[UIImage imageNamed:@"icon_notif_recall.png"]; 
      annotationView.frame=CGRectMake(0,0,25,25); 
     } 
    }else{ 
     annotationView=(MKAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:@"pin"]; 
     if (annotationView==nil){ 
      annotationView=[[MKAnnotationView alloc]initWithAnnotation:[kingpinAnnotation.annotations anyObject]reuseIdentifier:@"pin"]; 
      annotationView.canShowCallout=YES; 

      annotationView.image=[UIImage imageNamed:@"icon_notif_recall.png"]; 
      annotationView.frame=CGRectMake(0,0,25,25); 
     } 
    } 
    return annotationView; 
}else if([annotation isKindOfClass:[REC_CustomAnnotation class]]){//Check that is our custom pin class 
    REC_CustomAnnotation *myLocation = (REC_CustomAnnotation *)annotation; 
    MKAnnotationView *annotationView=[mapView dequeueReusableAnnotationViewWithIdentifier:@"REC_CustomAnnotation"]; 

    if(annotationView==nil){ 
     annotationView=myLocation.annotationView; 
    }else{ 
     annotationView.annotation=annotation; 
    } 
    return annotationView; 
}else{ 
    return annotationView; 
} 

}

그러나 나는 어디가 문제인지 모르겠다 : 나는 관련 코드이라고 생각합니다. 문제가 무엇인지 또는 시도 할 사항에 대한 생각은 크게 감사 할 것입니다.

답변

0

사실 위에 게시 된 기능은 사실 문제였습니다. 그러나, 나는 두려움이 어떻게 작용했는지를 이해하는 측면에서 완전히 잘못된 길을 가고있었습니다.

-(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation{ 
MKAnnotationView *annotationView = nil; 
if ([annotation isKindOfClass:[KPAnnotation class]]) { 
    KPAnnotation *a = (KPAnnotation *)annotation; 
    if ([annotation isKindOfClass:[MKUserLocation class]]){ 
     return nil; 
    } 
    if (a.isCluster) { 
     annotationView = (MKAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:@"cluster"]; 
     if (annotationView == nil) { 
      annotationView = [[MKAnnotationView alloc] initWithAnnotation:a reuseIdentifier:@"cluster"]; 
     } 
     annotationView.image=[UIImage imageNamed:@"icon_notif_recall.png"]; 
     annotationView.frame=CGRectMake(0,0,25,25); 
    }else { 
     annotationView = (MKAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:@"pin"]; 
     if (annotationView == nil) { 
      annotationView = [[MKAnnotationView alloc] initWithAnnotation:[a.annotations anyObject] reuseIdentifier:@"pin"]; 
     } 

     KPAnnotation *thisKPAnnot=(KPAnnotation *)annotation; 
     NSMutableArray *arrayOfAnnots = [NSMutableArray arrayWithArray:[[thisKPAnnot annotations] allObjects]]; 
     if([arrayOfAnnots count]==1){ 
      REC_CustomAnnotation *thisAnnot=(REC_CustomAnnotation *)[arrayOfAnnots objectAtIndex:0]; 
      if(thisAnnot.type==1){ 
       annotationView.image=[UIImage imageNamed:@"icon_notif_facebook.png"]; 
      }else if(thisAnnot.type==2){ 
       annotationView.image=[UIImage imageNamed:@"icon_notif_twitter.png"]; 
      }else if(thisAnnot.type==3){ 
       annotationView.image=[UIImage imageNamed:@"icon_notif_instagram.png"]; 
      }else if(thisAnnot.type==4){ 
       annotationView.image=[UIImage imageNamed:@"icon_notif_foursquare.png"]; 
      }else if(thisAnnot.type==5){ 
       annotationView.image=[UIImage imageNamed:@"icon_notif_camera.png"]; 
      }else{ 
       annotationView.image=[UIImage imageNamed:@"icon_notif_recall.png"]; 
      } 
     }else{annotationView.image=[UIImage imageNamed:@"icon_notif_recall.png"];} 
     annotationView.frame=CGRectMake(0,0,25,25); 
    } 
    annotationView.canShowCallout = YES; 
} 
return annotationView; 

}

나는이 미래에 사람을 돕는 끝 희망이 작업 모두를 얻었다.

관련 문제