I am writing an iOS 5 application that tracks the user's location in real time, building a course on MKMapView. Whenever a GPS reading occurs, I would like a polyline to be drawn between the current and old locations, eventually forming the track (or breading) that the user was traveling in.
I convenient to use MKPolylineand MKPolylineViewto draw the track, assuming that I have all CLLocationCoordinate2Dthe coordinates in advance, using code similar to the following:
MKPolyline *route = [MKPolyline polylineWithCoordinates:coordinates count:[self.coordinateArray count]];
[mapView addOverlay:route];
However, since I only get CLLocationCoordinate2Dreal-time coordinates (as I call the delegate method locationManager:didUpdateToLocation:fromLocation:), I'm not sure what the best way is to draw new polylines.
Can I expand existing lines (for example, add to a coordinatesC-based array ) without having much experience with C, I'm not sure how to do this) or do I need to create a new polyline between the next two coordinates (although I heard that too can many individual polylines on a card affect performance and memory usage ...)?
Thanks in advance.
source
share