简体   繁体   中英

Track user through GPS ,ios

我需要通过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

http://developer.apple.com/library/ios/#documentation/MapKit/Reference/MKPolyline_class/Reference/Reference.html#//apple_ref/doc/c_ref/MKPolyline

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM