title: MKMapview annotation dynamic pin image changes after zooming
body: <p>I am working on a little project that shows 7 different types of annotations on the map. My annotations are taken from a url result in array and I parse it using JSON. I have lots of annotations and everything seems to look good once the map loads. After zooming in and zooming out, the the pin images changes for some reason to the wrong pin image (a specific image, no clue why).</p>
  
  <p>I am sure I am missing something here...may you please help :) ? </p>
  
  <p>Here's one part of my code, let me know if you need anymore of it:</p>
  
  <pre><code>-(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id&lt;MKAnnotation&gt;)annotation{
  
  static NSString *identifier;
  
  if(_mapView.tag==1){identifier = @"TurbulencePin";}
  if(_mapView.tag==2){identifier = @"IcingPin";}
  if(_mapView.tag==3){identifier = @"WindsPin";}
  if(_mapView.tag==4){identifier = @"TemperaturePin";}
  if(_mapView.tag==5){identifier = @"CloudsPin";}
  if(_mapView.tag==6){identifier = @"VisibilityPin";}
  if(_mapView.tag==7){identifier = @"MultiplePin";}
  
  
  if ([annotation isKindOfClass:[MKUserLocation class]])
      return nil;
  
  if ([annotation isKindOfClass:[Annotation class]]) {
  
      CustomAnnotationView* annotationView = (CustomAnnotationView*)[mapView dequeueReusableAnnotationViewWithIdentifier:identifier];
      annotationView = nil;
  
      if (annotationView == nil) {
  
          annotationView = [[CustomAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier];
          annotationView.enabled = YES;
          annotationView.canShowCallout = YES;
  
  
          UIImage *img = [UIImage imageNamed:[NSString stringWithFormat:@"%@.png",identifier]];
          annotationView.image = img;
  
      }
  else
      {
  
          annotationView.annotation = annotation;
  
      }
  
  
      return annotationView;
  
  }
  return nil;
  
  }
  </code></pre>
  
  <hr>
  
  <p><strong>Update:</strong></p>
  
  <p>Based upon feedback of others, I've modified the code for the image setting to be as follows:</p>
  
  <pre><code> Annotation *myCustomAnn = (Annotation *)annotation;
   NSString *imgName = myCustomAnn.imageName;
   UIImage *img = [UIImage imageNamed:[NSString stringWithFormat:@"%@Pin.png",imgName]];
   annotationView.image = img;
  
   return annotationView;
  </code></pre>
  
  <p>Plus, I removed the <code>annotationView = nil;</code></p>
  
  <p>However, I cannot set the image name in the annotation.m as a hardcoded value because I need to display a different pin image for each annotation. I'm sure that there is an explanation but the only value that I can get from the annotation.m under the mapView:viewForAnnotation: is the annotation coordinates (<code>myCustomAnn.coordinate.latitude</code> and <code>myCustomAnn.coordinate.longitude)</code>, I have no clue how to get other properties from the annotation.m</p>
  
  <p>The other properties, such as title, imgname etc comes back as null</p>