我需要通过gps跟踪用户位置。我需要在路径上显示一条折线,说明用户的行进路线。还需要计算距离,速度和经过时间。请通过一些教程来指导我。
Retain the user's navigation locations form the following delegate method.
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation {
}
By using the following delegate method pass the overlay view.
- (MKOverlayView *)mapView:(MKMapView *)mapView viewForOverlay:(id <MKOverlay>)overlay
{
if([overlay class] == MKPolyline.class)
{
MKOverlayView* overlayView = nil;
MKPolyline* polyline = (MKPolyline *)overlay;
MKPolylineView * routeLineView = [[MKPolylineView alloc] initWithPolyline:polyline];
routeLineView.fillColor = [UIColor blueColor];
routeLineView.strokeColor = [UIColor blueColor];
routeLineView.lineWidth = 3;
routeLineView.lineCap = kCGLineCapSquare;
overlayView = routeLineView;
return overlayView;
} else {
return nil;
}
}
For creating polyline, refer the following
Regards, Arun.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.