对iOS
[用户跟踪视图]使用Map kit
MKPolylineView
。它显示了一些特定的距离,但没有显示长距离。
这是我的代码:
-(void)viewDidLoad { [super viewDidLoad];
appdelegate=[[UIApplication sharedApplication]delegate];
// Do any additional setup after loading the view, typically from a
nib.
self.mapView=[[MKMapView
alloc]initWithFrame:CGRectMake(0, 0, 320, 568)];
self.mapView.delegate = self; self.mapView.showsUserLocation = YES;
self.mapView.userInteractionEnabled = YES; //
self.mapView.userTrackingMode = MKUserTrackingModeFollowWithHeading;
[self.view addSubview:self.mapView];
[self configureRoutes];
}
- (MKOverlayView *)mapView:(MKMapView *)mapView viewForOverlay:(id <MKOverlay>)overlay
{
NSLog(@"%@ test 2----- %@", self, NSStringFromSelector(_cmd));
MKOverlayView* overlayView = nil;
if(overlay == self.routeLine)
{
//if we have not yet created an overlay view for this overlay, create it now.
// if (self.routeLineView) {
// [self.routeLineView removeFromSuperview];
// }
self.routeLineView = [[MKPolylineView alloc] initWithPolyline:self.routeLine];
self.routeLineView.fillColor = [UIColor redColor];
self.routeLineView.strokeColor = [UIColor redColor];
self.routeLineView.lineWidth = 5;
overlayView = self.routeLineView;
}
return overlayView;
}