I am using the iOS 7 MapKit APIs to produce 3D camera movements on a map that displays an MKDirectionsRequest-produced path. The path is rendered by MKOverlayRenderer like s
OK, I have fixed this problem with slow MKPolylineRenderer rendering to slowly. First use the Breadcrumb renderer from [Apple breadcrumb sample][1]https://developer.apple.com/library/content/samplecode/Breadcrumb/Introduction/Intro.html#//apple_ref/doc/uid/DTS40010048-Intro-DontLinkElementID_2
Simply instead of adding points dynamically to the CrumpPath just add your path.
Secondly, now that you have fixed MKPolylines faulty rendering, you need to speed it up because its horribly slow.
See this answer on stack overflow: https://stackoverflow.com/a/28964449/7313127
To adapt this to the "CrumbPathRenderer" just add this obj C code to the drawMapRect function (This is just quick and dirty)
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
CADisplayLink *displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(update)];
[displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
});
Create an update method on the renderer that calls setNeedsDisplay
-(void) update {
[self setNeedsDisplay];
}
I also put renderer.setNeedsDisplay in (but its probably not needed)
func mapView(_ mapView: MKMapView, regionWillChangeAnimated animated:Bool)
{
crumbRenderer.setNeedsDisplay()
}
Important NOTE: This will render flawlessly but will use 100% CPU. So to not drain the battery of the phone and thrash the CPU, in the update method keep a static and only call setNeedsDisplay every third time display link calls it. Remember CA display link is a hardware refresh timer.
If you follow this (hastily composed) answer which took me days to figure out, you will use about 30% CPU and your map paths with never show up ugly.
Hey apple, wanna fix MKMapView?