MKRoute update MKPolyline Overlay when current Location changes

烈酒焚心 提交于 2019-12-10 08:59:13

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!