Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing pin color MKMapView

I add annotations to my map in this way:

MyAnnotation *annotationPoint2 = [[MyAnnotation alloc] init];
annotationPoint2.coordinate = anyLocation;
annotationPoint2.title = [NSString stringWithFormat:@"%@", obj];
annotationPoint2.subtitle = @"";  //or set to nil
annotationPoint2.keyValue = [NSString stringWithFormat:@"%@", key];
[mapPins addAnnotation:annotationPoint2];

The pins are all red, and I would like them all green. How can I change the color? I have tried the following, but it still gives a red mark:

annotationPoint2.pinColor = MKPinAnnotationColorGreen;
like image 454
Alessandro Avatar asked Oct 12 '12 12:10

Alessandro


1 Answers

- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation 
  {
    MKPinAnnotationView *annView=[[MKPinAnnotationView alloc]initWithAnnotation:annotation reuseIdentifier:@"pin"];
    annView.pinColor = MKPinAnnotationColorGreen;
    return annView;
  }
like image 190
casillas Avatar answered Sep 20 '22 11:09

casillas