尝试实现折线但不会出现

时间:2014-09-15 18:21:34

标签: ios objective-c cllocationmanager mkoverlay

我正在尝试在我的轨道应用程序中找到一条折线。我已经经历了各种各样的问题和网站,但我无法猜出我哪里出错了。如果有人可以帮助我,那会很棒吗? :)

我的代码 - >

CLLocation *currentLocation = [locations lastObject];

[linerArray addObject:currentLocation];

CLLocationDegrees lat = currentLocation.coordinate.latitude;
CLLocationDegrees lngt= currentLocation.coordinate.longitude;

CLLocationCoordinate2D lccoordinates = CLLocationCoordinate2DMake(lat, lngt);






NSInteger calculateCoordinates= linerArray.count;
CLLocationCoordinate2D coordinates[calculateCoordinates];


for (NSInteger initialStart= 0; initialStart < calculateCoordinates; initialStart ++) {
    CLLocation *lct = [linerArray objectAtIndex:initialStart];
    CLLocationCoordinate2D cord2 = lct.coordinate;

    coordinates[initialStart] = cord2;
}

//drawing a polyline
MKPolyline *pline = [MKPolyline polylineWithCoordinates:coordinates count:calculateCoordinates];
    [self.viewMap addOverlay:pline];

}

//Designing overlay polyline or setting polyine view


-(MKOverlayRenderer *)mapView:(MKMapView *)mapView rendererForOverlay:(id<MKOverlay>)overlay{
    MKPolylineRenderer *polylineRender = [[MKPolylineRenderer alloc] initWithOverlay:overlay];
    polylineRender.lineWidth = 7.0f;
    polylineRender.strokeColor = [UIColor blueColor];
    return polylineRender;
}

0 个答案:

没有答案