I've a mapview with many pins that have different images! Everything work good but if I change the maptype... normal.. satellite or ibrid.. i lose my image and my pin became the standars red pins! Can I change the maptype without change anything?
I use this code to assign the different images:
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
{
annView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:nil];
if([annotation.title compare:@"Biggest"]==0){imageView = [UIImage imageNamed:@"pin.png"];annView.image=imageView;}
if([annotation.title compare:@"Campo sportivo"]==0){imageView = [UIImage imageNamed:@"mondo.png"];annView.image=imageView;}
if([annotation.title compare:@"BlackSheep ADV"]==0){imageView = [UIImage imageNamed:@"an.png"];annView.image=imageView;}
annView.pinColor = MKPinAnnotationColorRed;
UIButton *advertButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[advertButton addTarget:self action:@selector(button:) forControlEvents:UIControlEventTouchUpInside];
annView.rightCalloutAccessoryView = advertButton;
annView.animatesDrop = TRUE;
annView.canShowCallout = YES;
annView.calloutOffset = CGPointMake(0, 5);
if ([annotation isKindOfClass:[MKUserLocation class]]){
return nil;
}
return annView;
}