0

I am using this sample app to make route

http://blog.kadirpekel.com/2010/05/30/drawing_routes_onto_mkmapview_using_unofficial_google_maps_directions_api/

It will call the routing api and parse the result.

Then a new layer is added above the map with the route between A and B.

My problem is how can i place two color pins ? Right now Its showing 2 red color pins. But I need 1 red and 1 green.

I am trying to work with this delegate, but its not helping me

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
Tariq
  • 9,861
  • 12
  • 62
  • 103

1 Answers1

0
- (MKAnnotationView *)mapView:(MKMapView *)mapView 
            viewForAnnotation:(id <MKAnnotation>)annotation {

    if(annotation == yourFirstAnnotation)
{
MKPinAnnotationView *annView=[[MKPinAnnotationView alloc] initWithAnnotation:yourFirstAnnotation reuseIdentifier:[annotation title]];
            annView.pinColor = MKPinAnnotationColorRed;
            annView.animatesDrop=NO;
            annView.canShowCallout = YES;
            return [annView autorelease];
}
else
if(annotation == yourSecondAnnotation)
{
MKPinAnnotationView *annView=[[MKPinAnnotationView alloc] initWithAnnotation:yourSecondAnnotation reuseIdentifier:[annotation title]];
            annView.pinColor = MKPinAnnotationColorGreen;
            annView.animatesDrop=NO;
            annView.canShowCallout = YES;
            return [annView autorelease];
}
}

I think if it doesn't work make use of isEqual: instead of ==.

visakh7
  • 26,380
  • 8
  • 55
  • 69