0

I have view with segment's buttons. on clicking on button with index "1", it should show mapview with some overlays. For this reason, I have the following code:

    {
        [_routeMap setHidden:NO];
        [self drawTheMap];
        [_routeMap setRegion:_region animated:YES];
        [_routeMap regionThatFits:_region];
        [_navBar setHidden:NO];
        NSLog(@"overlays: %@", _routeMap.overlays);
    }
    -(void)drawTheMap
    {
        [_routeMap setFrame:CGRectMake(0, 44, 320, 416)];
        for (int i=0; i<[_arrayOfPoints count]; i++) {
            CLLocation* location = [[CLLocation alloc] initWithLatitude:[[_arrayOfPoints objectAtIndex:i] latitude] 
                                                          longitude:[[_arrayOfPoints objectAtIndex:i] longitude]];

    ... 
        MKCircle * dot = [MKCircle circleWithCenterCoordinate:location.coordinate radius:radius];
            [_routeMap addOverlay:dot];

    ...  
    }
    ...
    }
    - (MKOverlayView *)mapView:(MKMapView *)mapView viewForOverlay:(id <MKOverlay>)overlay
{
    MKCircleView *circleView = [[MKCircleView alloc] initWithCircle:overlay];
    circleView.lineWidth = 1.0;
    circleView.strokeColor = [UIColor orangeColor];
    [circleView setFillColor:[UIColor orangeColor]];

    return [circleView autorelease];
}

but the viewForOverlay method is never called =(. NSLog shows me that mkmapview contain some overlays. Can anybody help me?

Fran Sevillano
  • 8,103
  • 4
  • 31
  • 45
Vov4yk
  • 1,080
  • 1
  • 9
  • 13
  • Is the map view's delegate property set? Also, where you call addOverlay, log the coordinate and radius values. –  Sep 19 '11 at 15:28

1 Answers1

2

In the method -(void)drawTheMap , instead of [_routeMap addOverlay:dot]; try [self addOverlay:dot];