0
我有段的按鈕視圖。點擊索引爲「1」的按鈕時,它應該顯示帶有一些疊加層的mapview。出於這個原因,我有以下代碼:viewForOverlay從未被稱爲
{
[_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包含一些覆蓋 任何人可以幫助我
是否設置了地圖視圖的委託屬性?另外,在調用addOverlay時,記錄座標和半徑值。 – Anna