在我的应用程序中,我正在地图上绘制折线叠加层,点从didUpdateUserLocation:
委托方法获得的用户位置开始。
但由于某种原因,它总是从非洲开始。
可能是什么原因?我是否必须为折线指定任何起始坐标?
-(void)drawTheRoute{
[self.mapViewTrace removeOverlay:self.polyline];
CLLocationCoordinate2D coordinates[arrayOfPoint.count];
int i = 1;
for (TMPoint *point in arrayOfPoint) {
coordinates[i] = point.coordinate;
i++;
}
MKPolyline *polyline = [MKPolyline polylineWithCoordinates:coordinates count:arrayOfPoint.count];
[self.mapViewTrace addOverlay:polyline];
self.polyline = polyline;
self.lineRenderer = [[MKPolylineRenderer alloc] initWithPolyline:self.polyline];
self.lineRenderer.strokeColor = [UIColor redColor];
self.lineRenderer.lineWidth = 5;
}
- (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation{
TMPoint *point = [[TMPoint alloc] initWithCoordinate:userLocation.location.coordinate withSpeed:userLocation.location.speed];
[arrayOfPoint addObject:point];
[self drawTheRoute];
}