I am trying to add multiple pin at the same location.
for (int i = 0; i < [arrListing count]; i++) {
List *obj = [arrListing objectAtIndex:i];
NSLog(@"Title %@",obj.Title);
CLLocationCoordinate2D annotationCoord;
annotationCoord.latitude = [obj.lat floatValue];
annotationCoord.longitude = [obj.log floatValue];
MKPointAnnotation *annotationPoint = [[MKPointAnnotation alloc] init];
annotationPoint.coordinate = annotationCoord;
annotationPoint.title = obj.Title;
[mapView addAnnotation:annotationPoint];
}
the above code represent adding mulitiple annotation but many pin are at the same location
So I can see only. last and the second last at that point. below is the code for the viewForAnnotation
- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation{
MKPinAnnotationView *annView = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:@"annView"];
if (!annView) {
annView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"annView"];
annView.pinColor = MKPinAnnotationColorRed;
annView.animatesDrop = YES;
annView.canShowCallout = YES;
NSLog(@"iRow :%d",iRow);
annView.tag = iRow++;
UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
annView.rightCalloutAccessoryView = rightButton;
NSLog(@"if condition");
}
else
{
annView.annotation = annotation;
NSLog(@"else condition");
}
return annView;
}