Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MKmapView Overlay drawing shows color patches iOS 10

enter image description here

I am drawing MKPolyLine over MKMapView. Before iOS 10 is was working fine. In iOS 10 its showing color patches other than routes.

 - (MKOverlayRenderer *)mapView:(MKMapView *)mapView rendererForOverlay:(id<MKOverlay>)overlay
 {
 [![enter image description here][1]][1]if ([overlay isKindOfClass:[MKPolyline class]]) {
    MKPolyline *route = overlay;
    @try {

        MKPolylineRenderer *routeRenderer = [[MKPolylineRenderer alloc] initWithPolyline:route];
        routeRenderer.strokeColor = [UIColor colorWithRed:20/255.0 green:153/255.0 blue:255/255.0 alpha:1.0];
        routeRenderer.lineWidth = 3;
        [routeRenderer setNeedsDisplay];
        return routeRenderer;
    }
    @catch (NSException *exception) {
        NSLog(@"exception :%@",exception.debugDescription);
    }

}
else return nil;
}
like image 373
Mahendra Avatar asked Sep 30 '16 05:09

Mahendra


1 Answers

Its look like iOS 10 bug, I spend lot of time to "hack" this bug.

I found only one solution when I redraw MKPolyline(remove old and add new) it should be call it in dispatch_after, it look like it should be redraw when map make shape. (imho)

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1.5 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ // Add MKPolyline to mapView });

I too redraw MKPolyline when mapView delegate call

- (void)mapViewDidFinishRenderingMap:(MKMapView *)mapView fullyRendered:(BOOL)fullyRendered

It is required more tests but it look it works

like image 114
Jan Timar Avatar answered Nov 02 '22 17:11

Jan Timar