2

I want to add annotations to a route between 2 locations on the map. That annotation would be like checkmark in Google Map. I have drawn route using MKPolyline. Now to add several annotations what should I do?

Am a newbie. so please dont mind me asking this question.

Thanks in advance.

1 Answer 1

2

As, I think that this was a good question and many have faced this, I am giving its answer. We need to implement this delegate method of MKAnnotationView..

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

Also we need to have an array of all the annotation in the route like this..

    self.mRouteArray = [mDirections routeArray];
    NSArray *_routeWayPoints1 = [[mRouteArray objectAtIndex:0] wayPoints];
    NSArray *mPlacetitles = [[mRouteArray objectAtIndex:0] mPlaceTitle];

    for(int idx = 0; idx < [_routeWayPoints1 count]; idx++)
    {
        mBetweenAnnotation = [[SBRouteAnnotation alloc] initWithCoordinate:[[_routeWayPoints1 objectAtIndex:idx]coordinate]
                                                                  title:[mPlacetitles objectAtIndex:idx]
                                                         annotationType:SBRouteAnnotationTypeWayPoint];

        [self.mAnnotations addObject:mBetweenAnnotation];
        [mBetweenAnnotation release];
    }

this will load all the annotations between the route. May this will help others.. Happy Coding...

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.