我有段的按钮查看。在点击索引为“1”的按钮时,它应该显示带有一些叠加层的mapview。出于这个原因,我有以下代码:
{
[_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];
}
但是从不调用viewForOverlay方法=(。 NSLog向我显示mkmapview包含一些叠加层。 有谁能够帮我?
答案 0 :(得分:2)
在方法-(void)drawTheMap
中,而不是[_routeMap addOverlay:dot];
尝试[self addOverlay:dot];