I am updating the iOS 6 application for iOS 7 and found that the overlay handlers are completely changed in iOS 7.
We draw a light gray overlay throughout the map. In iOS 6, everything works fine, in iOS 7 we do not get overlays.
In viewDidLoad , I have the following:
CLLocationCoordinate2D worldCoords[4] = { {90,-180}, {90,180}, {-90,180}, {-90,-180} }; MKPolygon *worldOverlay = [MKPolygon polygonWithCoordinates:worldCoords count:4]; [self.mapView addOverlay:worldOverlay];
Then for iOS 6.,.
- (MKOverlayView *)mapView:(MKMapView *)mapView viewForOverlay:(id<MKOverlay>)overlay { if (![overlay isKindOfClass:[MKPolygon class]]) { return nil; } MKPolygon *polygon = (MKPolygon *)overlay; MKPolygonView *view = [[MKPolygonView alloc] initWithPolygon:polygon]; view.fillColor = [[UIColor darkGrayColor] colorWithAlphaComponent:0.4]; return view; }
For iOS 7.,.
- (MKOverlayRenderer *)mapView:(MKMapView *)mapView rendererForOverlay:(id<MKOverlay>)overlay { if (![overlay isKindOfClass:[MKPolygon class]]) { return nil; } MKPolygon *polygon = (MKPolygon *)overlay; MKPolygonRenderer *renderer = [[MKPolygonRenderer alloc] initWithPolygon:polygon]; renderer.fillColor = [[UIColor darkGrayColor] colorWithAlphaComponent:0.4]; return renderer; }
Using breakpoints, I verified that the mapView:rendererForOverlay: method is mapView:rendererForOverlay: called and that the renderer returned object has the fillColor property correctly.
Any thoughts on why we don't see overlays?
source share