我正在写一个iOS 5应用程序,它实时跟踪用户的位置,在MKMapView
上绘制他们的路线。无论何时进行GPS读取,我都希望在当前位置和旧位置之间绘制折线,最终形成用户旅行的轨迹(或面包屑)。扩展MKPolylines或创建多个MKPolylines?
我愿意使用MKPolyline
和MKPolylineView
划出一道轨迹,假设我都提前CLLocationCoordinate2D
坐标,使用类似的代码如下:
MKPolyline *route = [MKPolyline polylineWithCoordinates:coordinates count:[self.coordinateArray count]];
[mapView addOverlay:route];
然而,因为我只得到CLLocationCoordinate2D
坐标实时(如调用locationManager:didUpdateToLocation:fromLocation:
委托方法)我不确定绘制新多段线的最佳方式。
我可以扩展现有生产线(即增加了基于C-coordinates
阵列 - 没有多少Ç经验我不确定如何做到这一点),或者我需要创建接下来的两个坐标之间的新的折线(虽然我听说在地图上有太多的单独折线会影响性能和内存使用...)?
在此先感谢。
你见过苹果示例应用[Breadcrumb](http://developer.apple.com/library/ios/#samplecode/Breadcrumb/Introduction/Intro.html)吗? – Anna 2012-04-07 12:53:43