Objective c MKPolyline-won';t显示

Objective c MKPolyline-won';t显示,objective-c,ios,mapkit,Objective C,Ios,Mapkit,我试图让我的MKPolyline显示出来,我想我几乎什么都做对了,但我肯定错过了什么。没有错误代码,地图显示良好,否则我可以放下注释引脚 h @interface SatFinderViewController: UIViewController <MKMapViewDelegate> { IBOutlet MKOverlayView *mapView; IBOutlet MKMapView *map; MKMapView *_mapView; MKPolyline *_route

我试图让我的MKPolyline显示出来,我想我几乎什么都做对了,但我肯定错过了什么。没有错误代码,地图显示良好,否则我可以放下注释引脚

h

@interface SatFinderViewController: UIViewController 
<MKMapViewDelegate>
{
IBOutlet MKOverlayView *mapView;
IBOutlet MKMapView *map;
MKMapView *_mapView;
MKPolyline *_routeLine;
MKPolylineView *_routeLineView;

}
@property (nonatomic, retain) IBOutlet MKMapView *map;
@property (nonatomic, retain) MKAnnotationView *mapAView;
@property (nonatomic, retain) MKOverlayView *mapView;
@property (nonatomic, retain) MKPolyline *routeLine;
@property (nonatomic, retain) MKPolylineView *routeLineView;

-(void)calculate;
-(void)loadRoute;

@end
@接口SatFinderViewController:UIViewController
{
IBOutlet MKOverlayView*地图视图;
IBMKMAPVIEW*地图;
MKMapView*\u mapView;
MKPolyline*_routeLine;
MKPolylineView*_routeLineView;
}
@属性(非原子,保留)IBMMapView*map;
@属性(非原子,保留)MKAnnotationView*mapAView;
@属性(非原子,保留)MKOverlayView*mapView;
@属性(非原子,保留)MKPolyline*routeLine;
@属性(非原子,保留)MKPolylineView*routeLineView;
-(无效)计算;
-(无效)装货路线;
@结束
m

-(void)calculate
{ ...

[map removeOverlay:self.routeLine];
self.routeLine = nil;   
[self loadRoute];
[map addOverlay:routeLine];
[map setNeedsDisplay];

}

-(void) loadRoute
{
SatFinderAppDelegate *appdel = (SatFinderAppDelegate *)[[UIApplication sharedApplication]delegate];
float s = [appdel.location floatValue];

CLLocationCoordinate2D *locations = malloc(sizeof(CLLocationCoordinate2D) * 2);

CLLocationCoordinate2D satcoord = CLLocationCoordinate2DMake(0, s);
CLLocationCoordinate2D dishcoord = CLLocationCoordinate2DMake(pinlat, pinlon);

locations[0] = satcoord;
locations[1] = dishcoord;

NSLog(@"satcoord %f,%f", locations[0].latitude, locations[0].longitude);
NSLog(@"dishcord %f,%f", locations[1].latitude, locations[1].longitude);

// Create the polyline based on the array of points.   
routeLine = [MKPolyline polylineWithCoordinates:locations count:1];

[routeLineView setNeedsDisplay];

}
- (MKOverlayView *)mapView:(MKMapView *)map viewForOverlay:(id <MKOverlay>)overlay
{

routeLineView = [[MKPolylineView alloc] initWithPolyline:self.routeLine];
routeLineView.fillColor = [UIColor blueColor];
routeLineView.strokeColor = [UIColor blueColor];
routeLineView.lineWidth = 5;
return routeLineView;

}
-(无效)计算
{ ...
[地图移除覆盖:self.routeLine];
self.routeLine=nil;
[自载路线];
[地图添加覆盖:路线线];
[地图设置需要显示];
}
-(无效)装货路线
{
SatFinderAppDelegate*appdel=(SatFinderAppDelegate*)[[UIApplication sharedApplication]委托];
float s=[appdel.location floatValue];
CLLocationCoordinate2D*locations=malloc(sizeof(CLLocationCoordinate2D)*2);
CLLocationCoordinate2D卫星坐标=CLLocationCoordinate2DMake(0,s);
CLLocationCoordinate2D dishcoord=CLLocationCoordinate2DMake(pinlat,pinlon);
位置[0]=卫星;
地点[1]=迪斯科德;
NSLog(@“卫星%f,%f”,位置[0]。纬度,位置[0]。经度);
NSLog(@“dishcord%f,%f”,位置[1]。纬度,位置[1]。经度);
//基于点阵列创建多段线。

路线线=[MKPolyline polyline polyline with coordinates:位置计数:1]; [路由查看设置需要显示]; } -(MKOverlayView*)地图视图:(MKMapView*)地图视图覆盖:(id)覆盖 { routeLineView=[[MKPolylineView alloc]initWithPolyline:self.routeLine]; routeLineView.fillColor=[UIColor blueColor]; routeLineView.strokeColor=[UIColor blueColor]; routeLineView.lineWidth=5; 返回路线视图; }

应该是“计数:2”而不是“计数:1”

routeLine=[MKPolyline polylineWithCoordinates:locations count:1];
routeLine = [MKPolyline polylineWithCoordinates:locations count:1];