I have an MKMapView
that I need to display two types of overlay on. One is a tiled overlay that I use a subclass of MKOverlayView
and an MKCircleRenderer
.
My method is:
- (MKOverlayView *)mapView:(MKMapView *)mapView viewForOverlay:(id <MKOverlay>)overlay
but now I need to also render an MKCircle
I'm getting an compiler error of:
'Incompatible pointer types returning 'MKCircleRenderer *' from a function with result type 'MKOverlayView * _Nonnull'.
- (MKOverlayView *)mapView:(MKMapView *)mapView viewForOverlay:(id <MKOverlay>)overlay
{
if ([overlay isKindOfClass:[MKCircle class]]) {
MKCircleRenderer *circleView = [[MKCircleRenderer alloc] initWithOverlay:overlay];
circleView.strokeColor = [UIColor redColor];
circleView.fillColor = [[UIColor redColor] colorWithAlphaComponent:0.4];
return circleView;
} else {
TileOverlayView *view = [[TileOverlayView alloc] initWithOverlay:overlay];
view.tileAlpha = 1.0;
return view;
}
}
That is my code, I'm aware that initWithOverlay
is deprecated which I'm working on as another issue.