简体   繁体   English

通过GPS,iOS跟踪用户

[英]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 http://developer.apple.com/library/ios/#documentation/MapKit/Reference/MKPolyline_class/Reference/Reference.html#//apple_ref/doc/c_ref/MKPolyline

Regards, Arun. 问候,阿伦。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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