- (void)viewDidLoad
{
[super viewDidLoad];
CLLocationCoordinate2D currentLocation;
currentLocation.latitude = self.mapView.userLocation.location.coordinate.latitude;
currentLocation.longitude = self.mapView.userLocation.location.coordinate.longitude;
CLLocationCoordinate2D otherLocation;
otherLocation.latitude = [lati doubleValue];
otherLocation.longitude = [longi doubleValue];
MKPointAnnotation *mka = [[MKPointAnnotation alloc]init];
mka.Coordinate = otherLocation;
mka.title = @"!";
[self.mapView addAnnotation:mka];
self.mapView.delegate = self;
MKMapPoint *pointsArray = malloc(sizeof(CLLocationCoordinate2D));
pointsArray[0]= MKMapPointForCoordinate(currentLocation);
pointsArray[1]= MKMapPointForCoordinate(otherLocation);
routeLine = [MKPolyline polylineWithPoints:pointsArray count:2];
free(pointsArray);
[self.mapView addOverlay:routeLine];
}
我正在使用此代码显示坐标之间的折线,但我得到了这条直线。如何解决这个问题。