问题
I did google a lot but couldn t get this to work. In my MKMapView I have a custom MKAnnotationView that I can place anywhere and also that dot that is representing my current location. I can do "show directions" calculate MKDirections between my custom annotation and my current position and draw a MKPolyline overlay to show the MKRoute.
So far so good. If I am moving now towards my custom annotation, the Polyline Overlay does not update, does not substract the distance I already traveled.
I thought I have to redraw the polyline. In the CLLocation delegate
-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations {
I was trying to redraw it, but the behavior is strange. If I remove the old overlay and add a new one I have kind of blinking effect, it s not smooth, and if the current location changes direction like at a cross roads it redraws a different route sometimes and so on...
So what is the proper way to achieve this? Like in the maps app when you driving to somewhere and follow directions, the overlay is being updated smoothly.
I could not find any example code or snippets on how to realize this.
Objective-C please!
Thanks !
来源:https://stackoverflow.com/questions/31779235/mkroute-update-mkpolyline-overlay-when-current-location-changes